PostGis设置SRID(报错为org.postgresql.util.PSQLException:错误: Operation on mixed SRID geometries)
2017-11-29 09:03
1201 查看
postgresql执行语句报错:
[Err] 错误: Operation on mixed SRID geometries
经查询:
SELECT st_srid(f_geom) FROM t_g_edge
SRID为0
修改为4326,解决问题!!!
update t_g_edge set f_geom = st_geomfromtext(ST_AsText(f_geom),4326)
***************************************************************************************************************
问题处理来源:
http://blog.csdn.net/duanmuxiao/article/details/38902071
今天遇到一个问题:
org.postgresql.util.PSQLException:错误: Operation on mixed SRID geometrie
通过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)
[Err] 错误: Operation on mixed SRID geometries
经查询:
SELECT st_srid(f_geom) FROM t_g_edge
SRID为0
修改为4326,解决问题!!!
update t_g_edge set f_geom = st_geomfromtext(ST_AsText(f_geom),4326)
***************************************************************************************************************
问题处理来源:
http://blog.csdn.net/duanmuxiao/article/details/38902071
今天遇到一个问题:
org.postgresql.util.PSQLException:错误: Operation on mixed SRID geometrie
通过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)
相关文章推荐
- org.postgresql.util.PSQLException: 栏位索引超过许可范围:3,栏位数:2。
- org.postgresql.util.psqlexception总结
- org.postgresql.util.PSQLException: 栏位索引超过许可范围:3,栏位数:2。
- spark on yarn 报 org.apache.hadoop.util.Shell$ExitCodeException: 问题
- org.springframework.expression.spel.SpelEvaluationException: EL1004E: Method call: Method service() cannot be found on com.my.blog.springboot.thymeleaf.util.MethodTest type
- hadoop错误org.apache.hadoop.util.DiskChecker$DiskErrorException Could not find any valid local directory for
- 解决org.apache.jasper.JasperException: org.apache.jasper.JasperException: XML parsing error on file org.apache.tomcat.util.scan.MergedWebXml
- MyBatis3.4.0以上的分页插件错误:Could not find method on interface org.apache.ibatis.executor.statement.StatementHandler named prepare. Cause: java.lang.NoSuchMethodException: org.apache.ibatis.executor.stateme
- JAVA错误:org.apache.jasper.JasperException: java.lang.ClassCastException:org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apach
- java.lang.ClassCastException:org.apache.catalina.util.DefaultAnnotationProcessor错误
- Maven使用tomcat7-maven-plugin插件run时出现错误: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component
- java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener错误解决方案
- spring + ibatis错误总结org.springframework.web.util.NestedServletException: Request processing failed; n
- 分享以下编译错误:java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException的一种解决方法
- postgreSQL异常总结一:org.postgresql.util.PSQLException: 错误: 对关系 ppol 权限不够
- 执行Hive时出现org.apache.hadoop.util.RunJar.main(RunJar.java:136) Caused by: java.lang.NumberFormatException: For input string: "1s"错误的解决办法(图文详解)
- [置顶] spark2.2错误 java.lang.UnsupportedOperationException: No Encoder found for org.apache.spark.sql.Row解决
- 错误解决:java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to star
- java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException Android编译错误
- org.hibernate.hql.ast.QuerySyntaxException: unexpected token: on near line 1解决方案