Skip to content

Instantly share code, notes, and snippets.

@rbanick
Last active August 2, 2016 06:12
Show Gist options
  • Save rbanick/1810588a089dd835f554d5c0737b6f2c to your computer and use it in GitHub Desktop.
Save rbanick/1810588a089dd835f554d5c0737b6f2c to your computer and use it in GitHub Desktop.
-- You update the SRID for your table first. Then you reverse that update within a SQL query so you can transform the actual coordinates to their new EPSG.
-- Otherwise you'll have Lat/Long coordinates for a metric projection or vice-versa.
SELECT Updategeometry_columnetrySRID('table','geometry_column',new_EPSG);
ALTER TABLE table
ALTER COLUMN geometry_column TYPE geometry(geometry_type,new_EPSG) USING ST_Transform(ST_SetSRID(geometry_column,old_EPSG),new_EPSG);
SELECT ST_AsText(geometry_column) FROM table;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment