PostGis设置SRID(报错为org.postgresql.util.PSQLException:错误: Operation on mixed SRID geometries)
来源:互联网 发布:永宏plc最新编程软件 编辑:程序博客网 时间:2024/04/29 20:46
org.postgresql.util.PSQLException:错误: Operation on mixed SRID geometries
通过pgAdminIII工具看到其他表的SRID为-1,唯独报错的 表的SRID为4326,所以在网上找了找PostgreGis设置表的SRID的文章,后来找到一篇不错的文章,这里借鉴一下:
连接为:http://blog.csdn.net/cnhome/article/details/6990060(以防文件被删除,这里将重要的文字拷贝一份)
因为倒入shp时没有指定相应的SRID,会造成入库数据中SRID取值为-1。当知道了空间对象的坐标系时,如何将空间几何体修改为新的坐标系ID呢。
首先,修改geometry_columns表中对应字段的SRID为新的坐标系ID;
其次,修改beijing_highway表的定义,将enforce_dims_the_geom的定义的(st_srid(the_geom) = (-1))删除(注:此处the_geom是空间字段);
然后,更新数据内容 update table_name set the_geom = st_geomfromtext(ST_AsText(the_geom),4326)(注:此处4326为数据的坐标系ID);
最后,将enforce_dims_the_geom的定义(st_srid(the_geom) = (4326))加回去就可以变更SRID了。
如果是从一个坐标系向另外一个坐标系调整,就需要进行坐标系的变换了。这时候你可能会意识到,字段是只能增加,也就是插入。
此处可以参考别人的一篇博文,http://hi.baidu.com/jrc520/blog/item/d070d84385987c0072f05daf.html
采用postgis函数将墨卡托投影变成4326并插入空间数据库
QuanGuo=# insert into test values(1,'hahaha',st_transform(st_geomfromtext('POINT
(10070507.650288 4282901.6281314)',900913),4326));
INSERT 0 1
按着文章的步骤最后问题解决了。在这个过程中我还学到了一些东西,通过PGAdminIII工具可以看到PostgreGis库中的每一个表的Geometry字段的SRID的值也可以改变该值(表geometry_columns),但是只是改变这一个值是不起作用的,还有根据上面的步骤操作才可以。
上面的操作涉及到的sql语句为:
第一步:
通过PGAdminIII工具可以看到PostgreGis库中的每一个表的Geometry字段的SRID的值也可以改变该值(表geometry_columns),但是只是改变这一个值是不起作用的,还有根据上面的步骤操作才可以。
第二步:
alter table guanxian drop CONSTRAINT enforce_srid_the_geom
第三步:
update guanxian set the_geom = st_geomfromtext(ST_AsText(the_geom),-1)
- PostGis设置SRID(报错为org.postgresql.util.PSQLException:错误: Operation on mixed SRID geometries)
- PostGis设置SRID(报错为org.postgresql.util.PSQLException:错误: Operation on mixed SRID geometries)
- PostGIS空间数据库SRID背景知识
- postgreSQL异常总结一:org.postgresql.util.PSQLException: 错误: 对关系 ppol 权限不够
- 如何修改Postgresql中空间字段的SRID
- WKT、SRID、EPSG概念
- WKT、SRID、EPSG概念
- org.postgresql.util.PSQLException: ERROR: column "loginid" of relation "userinfo" does not exist
- Caused by: org.postgresql.util.PSQLException: 不良的类型值 long
- org.postgresql.util.PSQLException: 未设定参数值 2 的内容。
- Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "veh
- Mybatis:org.postgresql.util.PSQLException: ERROR: relation "summarytdglinfo" does not ex
- org.postgresql.util.PSQLException: 栏位索引超过许可范围:3,栏位数:2。
- Caused by: org.postgresql.util.PSQLException: ERROR: relation "item" does not exist
- Cause: org.postgresql.util.PSQLException: ERROR: cached plan must not change result type的前因后果
- Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "
- org.postgresql.util.PSQLException: 栏位索引超过许可范围:1,栏位数:0。
- SRID WKID 空间参考简介
- 读书札记-2013年12月
- 错题集
- 漂亮的草坪
- shell抓取百度和有道词典
- 多维数组的应用
- PostGis设置SRID(报错为org.postgresql.util.PSQLException:错误: Operation on mixed SRID geometries)
- GlusterFs 简介及与Openstack的集成
- DSP6000的几个简单优化技巧
- this.class.getClassLoader()怎么理解?
- 数字信号处理的学习资源
- send sendto ,recv recvfrom有什么区别
- 数据结构练习题――Hero In Maze 简单版
- HOJ 2430——Counting the algorithms(树状数组+贪心)
- shell文本过滤编程(七):awk之变量传递