导入pg的方法有很多,可以使用常见的GIS软件,如ArcGIS/QGIS。本文使用shp2pgsql
导入。
资源
帮助
shp2pgsql [OPTIONS] shapefile [schema.]table
参数如下:
PSQL Connection options:
-h, --host=HOSTNAME database server host or socket directory
-p, --port=PORT database server port number
-U, --username=NAME connect as specified database user
-W, --password force password prompt (should happen automatically)
-e, --exit-on-error exit on error, default is to continue
使用示例
这块以Ubuntu16.0.4为例
-
生成sql(以root用户执行如下代码)
shp2pgsql -s 4326:4490 -c gis_osm_landuse_a_free_1.shp>landuse.shp
-
导入数据(以postgres用户执行如下代码)
# 切换到postgres用户 su - postgres # 导入数据 psql -d osm -U postgres -f /home/yh/Downloads/china-latest-free/landuse.shp -W # 输入postgres数据库的密码按回车
执行导入,如图所示: