简体   繁体   English

如何更改几何列的SRID?

[英]How to change SRID of geometry column?

I have a table where one of the columns is a geometry column the_geom for polygons with an SRID. 我有一个表,其中一列是具有SRID的多边形的几何列the_geom I added a new column in the same table with exactly the same geometry data as the_geom . 我在同一个表中添加了一个新列,其中的几何数据与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? 这个新列的名称为the_geom4258因为我想将其SRID设置为4258.将几何的SRID更改为另一个坐标系的步骤是什么? 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. 您应该使用ST_Transform函数。 Also use the function AddGeometryColumn to create your new column, to ensure all the necessary constraints are also created: 还可以使用AddGeometryColumn函数创建新列,以确保还创建了所有必需的约束:

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. ST_SetSRID只设置投影标识符,但实际上并不转换几何。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM