Updating Geometry Columns for views in PostGIS

The recent upgrade to PostGIS has caused some issues with geometry types when creating views from geometry that don’t use the new typemod geometry modifiers. ┬áThe following workaround correctly inserts an entry into the geometry_columns view so you can see your data in QGIS and the like:

DROP VIEW myview;

CREATE OR REPLACE VIEW myview AS (

SELECT field1, field2, field3,

St_Transform(the_geom, 27700)::geometry(Point, 27700) as the_geom

FROM mytable

);

Change the geometry type and CRS as required.

Leave a Reply

Your email address will not be published. Required fields are marked *