从 SQL 创建 SHP

发布于 2024-08-31 04:17:46 字数 82 浏览 2 评论 0原文

是否可以使用 pgsql2shp 不使用 shell 将 sql 转换为 shp 文件?通过一些 SQL(postgis、postgresql)语法?

Is it possible convert sql to shp file using pgsql2shp without shell? Through some SQL (postgis, postgresql) syntax?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

久而酒知 2024-09-07 04:17:46

不调用 shell 是不可能的。但是,有两个可用的方法:

1)您可以在 postgresql 中使用不安全的语言(例如 python)创建一个函数,然后执行 pgsql2shp。这是一个丑陋的 hack,但具有通过 SQL 查询生成 shapefile 的优点。

2)您可以将sql结果转储到临时表中,其中几何列通过ST_AsText保存为文本。然后,您可以通过 sql COPY TO 命令将表转储到 csv,然后使用客户端脚本从 csv 重建 shapefile。

这些方法都不是完全令人满意的(特别是方法 2 可能会损失一些几何精度),但它们可能足以实现您的目标。

It is not possible without calling the shell. However, two kuldges are available:

1) You could create a function in an unsafe language (like python) within postgresql that then executes pgsql2shp. This is an ugly hack, but has the advantage of producing a shapefile by SQL query.

2) You could dump the sql results into a temporary table with the geometry column saved as text via ST_AsText. You can then dump the table to csv via the sql COPY TO command, and then reconstruct a shapefile from the csv later using a client side script.

Neither of these approaches is entirely satisfactory (approach 2 in particular may lose some of the precision of your geometry), but they may be enough to achieve your goal.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文