22

I have a table where one of the columns is a geometry column the_geom for polygons with an SRID. I added a new column in the same table with exactly the same geometry data as the_geom.

This new column has the name the_geom4258 because I want to set its SRID to 4258. What is the procedure to change the geometry's SRID to another coordinate system? Is it enough to apply the following query:

UPDATE table SET the_geom4258=ST_SetSRID(the_geom4258,4258);
Brad Koch
  • 19,267
  • 19
  • 110
  • 137
Z77
  • 1,097
  • 6
  • 19
  • 30

1 Answers1

30

You should use the ST_Transform function. Also use the function AddGeometryColumn to create your new column, to ensure all the necessary constraints are also created:

SELECT AddGeometryColumn('table','the_geom4258',4258, 'POLYGON', 2);

UPDATE table SET the_geom4258 = ST_Transform(the_geom,4258);

ST_SetSRID just sets the projection identifier, but does not actually transform the geometries.

amercader
  • 4,490
  • 2
  • 24
  • 26
  • Your answere is exactly what I need. So thank you very much indeed. There is just one small thing, now i got error: "ERROR: AddToPROJ4SRSCache: couldn't parse proj4 string: '+proj=tmerc +lat_0=0 +lon_0=16.5 +k=0.999900 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=ETRS89 +units=m +no_defs': unknown elliptical parameter name" Any clue what should I co correct now? – Z77 Jun 10 '10 at 09:54
  • 1
    Make sure there is a record for srid 4258 in the spatial_ref_sys table of your database. If there is a record, check that the projection parameters match the ones in here: http://spatialreference.org/ref/epsg/4258/postgis/ – amercader Jun 10 '10 at 10:21