1.工具pgsql2shp.exe
安装PostGIS时,会在其安装目录下生成shp2pgsql.exe。
![image](https://img.haomeiwen.com/i9726877/ecbf4f5ec561ba01.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
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. |
| -b | Use 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. |
| -r | Raw mode. Do not drop the gid
field, or escape column names. |
| -m filename | Remap 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个附属文件。 导出结果如下:
image.png
网友评论