zoukankan      html  css  js  c++  java
  • PostGIS 爆管分析管网、阀门数据处理,并导出shp

    背景

    在做爆管分析时,需要制作一些模拟数据。
    我先制作了一些管网以后,再将阀门数据放到管网上

    操作

    数据处理:

    1. 创建x1,y1字段
      ALTER TABLE fm ADD COLUMN x1 double precision;
      ALTER TABLE fm ADD COLUMN y1 double precision;

    2. 将管网表表x1、y1字段更新到阀门表,这里因为是模拟数据,所以思路是将gid相等的管网和阀门放一起
      update fm a set x1 = b.x1,y1=b.y1 from zy b where a.gid = b.gid

    3. 检查数据更新对不对
      select a.gid,a.x1,a.y1,b.gid,b.x1,b.y1 from fm a left join zy b on a.gid =b.gid

    4. 将x1、y1坐标更新到geom字段
      update fm set geom = ST_Geometryfromtext('point('||x1||' '||y1||')',3857);
      --POINT(12678475.5121968 2624441.96137548)

    5. 查看阀门是否都在管网上
      select a.gid from fm a,(select c.* from zy c ) b where ST_intersects(a.geom,b.geom)

    导出
    1. 数据更新完了以后,我需要将postgis中的数据导出成shp,以便去arcmap中查看
      故用到postgis插件的导出工具pgsql2shp
      [root@localhost ~]# yum install postgis25_12-utils postgis25_12-client postgis25_12 -y
    2. 检验是否安装成功
      [root@localhost ~]# pgsql2shp --help
    3. 导出
      [root@localhost ~]# pgsql2shp -f /data/fm.shp -h 192.168.1.** -u postgres -P password gw_iocs "select * from fm";
      导出结果
  • 相关阅读:
    python笔记之re模块学习
    python笔记之面向对象
    C# 静态类和非静态类(实例类)
    占位符的使用
    数据类型和数据类型转换
    win7 安装 memcached
    php 汉字转换成拼音
    apache window环境下本地配置虚拟主机
    在浏览器输入一个网址到得到页面的过程
    浅谈线程池ThreadPoolExecutor核心参数
  • 原文地址:https://www.cnblogs.com/giser-s/p/12396810.html
Copyright © 2011-2022 走看看