加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

PostGIS安装与SHP数据入库(两种方法)

发布时间:2020-12-13 17:00:22 所属栏目:百科 来源:网络整理
导读:postgis: http://postgis.net/ http://live.osgeo.org/zh/quickstart/postgis_quickstart.html cmd命令导入shp数据 : http://www.cnblogs.com/hl3292/archive/2011/03/02/1969135.html 工具导入shp数据: http://www.openlayers.cn/forum.php?mod=viewthrea
postgis:
http://postgis.net/
http://live.osgeo.org/zh/quickstart/postgis_quickstart.html

cmd命令导入shp数据http://www.cnblogs.com/hl3292/archive/2011/03/02/1969135.html
工具导入shp数据: http://www.openlayers.cn/forum.php?mod=viewthread&tid=10&extra=page %3D1

解决无空间数据库模版方法:http://blog.sina.com.cn/s/blog_a453947f0102vuid.html
postgis导入数据、geoserver与udig加载数据: http://www.myexception.cn/open-source/1809904.html

SHP图层 导入PostgreSQL
首先安装postgis_2_2_pg95.exe:设定创建空间数据库(重要),一路Next,会安装一个postgis_22_sample实例(先安装PostgreSQL,后运行Stack Bulider进行上述安装)


方法1:
1)新建数据库(如myT),选择以postgis_22_sample/template_postgis为模板(新建空间数据库)
2)利用PostGIS Shapefile and DBF Loader导入shp数据(Options下设为GBK,否则中文导不进去;shp路径应简单且为全英文,否则报错;设定SRID, 否则 uDig 不显示,一定要确定好坐标系对应的SRID的值,并且在Geoserver发布时“定义SRS”部分选择相同的坐标系


方法2:
使用cmd命令( PostgreSQL自带转换工具shp2pgsql)
1)
cd,d:,cd D:Program FilesPostgreSQL9.5bin
shp2pgsql-W GBK -s 2436C:UserszoezoeDesktopnewMap雨量计雨量监测器最新.shp rainStation>rainStation.sql
shp2pgsql-W GBK -s 2436C:UserszoezoeDesktopnewMap原图层主干路.shp zhuganlu>zhuganlu.sql
说明:
-W GBK 对中文进行编码
-s 2436 否则 uDig 不显示
2) 将生成的sql文件内容粘贴至SQL编辑器运行即可


备注:
1)如若创建不了以postgis_22_sample为模板的空间数据库,则可以:
新建普通数据库,运行如下sql语句即可变为空间数据库,然后进行shp图层的导入工作:
CREATE EXTENSION postgis;
-- Enable Topology
CREATE EXTENSION postgis_topology;
-- fuzzy matching needed for Tiger
CREATE EXTENSION fuzzystrmatch;
-- Enable US Tiger Geocoder
CREATE EXTENSION postgis_tiger_geocoder;
2)如若没有template_post模版,则可以:
SQL Shell(psql):连接到template1数据库后,执行
template1=#create database template_postgis with template=template1;
template1=#update pg_database set datistemplate=TRUE where datname='template_postgis';
template1=#c template_postgis
template_postgis=#create language plpgsql;
template_postgis=#i /opt/locale/share/postgis/lwpostgis.sql;
template_postgis=#i /opt/locale/share/postgis/spatial_ref_sys.sql;
template_postgis=#GRANT ALL ON geometry_columns TO PUBLIC;
template_postgis=#GRANT ALL ON spatial_ref_sys TO PUBLIC;
template_postgis=#VACUUM FREEZE;
template_postgis=#q

uDig中展示PostGIS数据(postgis与udig版本要相对应,shp数据要有坐标系)
Import——Other——Data——PostGIS


GeoServer发布PostGIS数据







uDig中展示PostGIS数据(postgis与udig版本要相对应,shp数据要有坐标系)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读