admin 管理员组

文章数量: 1087677

pgsql2shp 导出.shp文件

1.工具pgsql2shp.exe

    安装PostGIS时,会在其安装目录下生成shp2pgsql.exe。

    

2.导出命令

pgsql2shp [<options>] <database> [<schema>.]<table>
pgsql2shp [<options>] <database> <query>

    命令中的参数含义如下:

参数含义
-f <filename>导出的shp文件名称
-h <host>主机地址
-p <port>端口号
-u <user>用户名
-P <password>密码
-g <geometry column>In the case of tables with multiple geometry columns, the geometry column to use when writing the shape file.
-bUse a binary cursor. This will make the operation faster, but will not work if any NON-geometry attribute in the table lacks a cast to text.
-rRaw mode. Do not drop the gid field, or escape column names.
-m filenameRemap identifiers to ten character names. The content of the file is lines of two symbols separated by a single white space and no trailing or leading space.

3.导出实例

    将数据库Testpg中的表nyc_streets导出,导出后文件的位置是E:/shp/。

pgsql2shp -f E:/shp/nyc_streets.shp -h localhost -u postgres -P 123456 -p 5433 Testpg  public.nyc_streets;

    或

pgsql2shp -f E:/shp/nyc_streets.shp -h localhost -u postgres -P 123456 -p 5433 Testpg  "SELECT * from  nyc_streets";

      默认情况下生成 nyc_streets.shp文件,以及另外4个附属文件。 导出结果如下:

    

本文标签: pgsql2shp 导出shp文件