postgis的空间数据如何导出shp文件

1.工具pgsql2shp.exe

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

![image](https://upload-images.jianshu.io/upload_images/9726877-ecbf4f5ec561ba01.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

2.导出命令

pgsql2shp []  [.]
pgsql2shp []  

命令中的参数含义如下:

| 参数 | 含义 |
| -f | 导出的shp文件名称 |
| -h | 主机地址 |
| -p | 端口号 |
| -u | 用户名 |
| -P | 密码 |
| -g | 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

你可能感兴趣的:(postgis的空间数据如何导出shp文件)