简体   繁体   English

如何在Postgis中更改SRID

[英]How to change SRID in Postgis

I am very green in both Postgis and Postgresql. 我在Postgis和Postgresql中都非常环保。 I wanted to alter the geom column in my table in order to change the SRID but I receive this error: 我想更改表中的geom列以更改SRID,但收到此错误:

cannot alter type of a column used by a view or rule
DETAIL:  rule _RETURN on view vw_select_location depends on column "geom"
CONTEXT:  SQL statement "ALTER TABLE public.ponds_data ALTER COLUMN geom TYPE  geometry(PointZM, 4210) USING ST_SetSRID(geom,4210);"
PL/pgSQL function updategeometrysrid(character varying,character varying,character varying,character varying,integer) line 81 at EXECUTE statement
SQL statement "SELECT UpdateGeometrySRID('','',$1,$2,$3)"
PL/pgSQL function updategeometrysrid(character varying,character varying,integer) line 5 at SQL statement. 

Please help. 请帮忙。 I wants to change the reference coordinate system to arc 1960. 我想将参考坐标系更改为arc 1960。

Read the error message carefully: you cannot change the column geom on table ponds_data because the view vw_select_location depends on it. 请仔细阅读错误消息:您无法更改表ponds_data上的列geom ,因为视图vw_select_location依赖于该视图。

Solution : first save the view definition in a file. 解决方案 :首先将视图定义保存在文件中。 You can find definition of the view in pgadmin or in psql. 您可以在pgadmin或psql中找到视图的定义。 In psql use the command 在psql中使用命令

\d+ vw_select_location

Then drop the view, change the column and recreate the view with the sql statement you saved before. 然后放下视图,更改列,并使用之前保存的sql语句重新创建视图。

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

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