开发者

How to change SRID of geometry column?

开发者 https://www.devze.com 2023-01-02 19:06 出处:网络
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.

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);


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消