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个附属文件。 导出结果如下:

    

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
要在PostGIS导出shp文件,有两种主要的方式可以使用。 第一种方式是借助PostGIS shapefile工具。具体操作可以参考\[1\]中的教程链接。你需要使用shp2pgsql.exe程序执行导出数据操作,并将结果导入到指定的数据库中。 第二种方式是调用PostGISpgsql2shp.exe程序。你需要先cd到PostgreSQL安装的bin目录,然后使用pgsql2shp.exe程序执行导出数据操作。具体的命令和参数可以参考\[2\]中的引用内容。 无论使用哪种方式,你都需要指定导出的路径和文件名,以及数据库、模式和表的信息。确保你设置了正确的参数,并按照指定的格式进行导出操作。 如果在Windows系统中导出shp文件时出现乱码问题,你可以在环境变量中设置PGCLIENTENCODING为GBK或GB18030,然后执行pgsql2shp命令。这样导出的shape文件中的属性数据编码就会正确显示,而不会出现乱码。具体的解决办法可以参考\[3\]中的引用内容。 希望以上信息对你有帮助! #### 引用[.reference_title] - *1* *2* [postgis导入导出shp文件](https://blog.csdn.net/Rainder_YL/article/details/116735795)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [PostGIS导入导出SHP文件常用命令](https://blog.csdn.net/weixin_39950824/article/details/111751462)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值