无法使用Windows 10上的PGSQL2SHP对每个日期导出ShapeFile

发布于 2025-02-09 08:45:56 字数 478 浏览 1 评论 0原文

我的PostgreSQL 11数据库中有一个表格,相同的linestring几何形状,但每个日期都有不同的属性(小时数据)。我试图将每个日期的属性导出到一个单独的shapefile中。我在Windows 10(x64)PC上,并尝试使用pgsql2shp实用程序。

以下代码行之有效(假设我想要第50个日期,所以1..50),但它输出了整个表(1..50.shp),而不是输出每个日期的单独表:

for %i in (1..50) ; do pgsql2shp -f %i.shp -h localhost -p my_port -u postgres -P my_code postgres public.my_table '"select * from my_table where date = $i"'; done

如何修复上述行以每个日期导出ShapeFiles?

I have a table in my PostgreSQL 11 database, same linestring geometry but different attributes (hourly data) for each date. I am trying to export the attributes for each date into a separate shapefile. I am on Windows 10 (x64) PC and trying to use the pgsql2shp utility.

The following line of code works (assume I want first 50 dates so 1..50), but it outputs the whole table (1..50.shp) instead of separate tables for each date:

for %i in (1..50) ; do pgsql2shp -f %i.shp -h localhost -p my_port -u postgres -P my_code postgres public.my_table '"select * from my_table where date = $i"'; done

How can I fix the above line to export shapefiles for each date?

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

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

发布评论

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

评论(1

无法言说的痛 2025-02-16 08:45:58
for /L %i in (1,1,50) do pgsql2shp -f %i.shp -h localhost -p my_port -u postgres -P my_code postgres public.my_table '"select * from my_table where date = %i"'

注意:

for /l < /code> stephan提到的语法。

半隆被视为分离器,与 space 相同的

SQL语句中的$ i应为%i以替换%i i的值。

;完成我不知道 - 可能需要。

如果将其作为批处理文件中的行执行,则每个%i都需要为%% i。这可能可以节省大量容易出错的重新打入。

for /L %i in (1,1,50) do pgsql2shp -f %i.shp -h localhost -p my_port -u postgres -P my_code postgres public.my_table '"select * from my_table where date = %i"'

Notes :

The for /L syntax as mentioned by Stephan.

The semicolon is seen as a separator, same as Space

The $i in the SQL statement should be %i to substitute %i's value.

The ; done I don't know about - it may be required.

If this is executed as a line in a batch file, each %i needs to be %%i. That might save a whole lot of error-prone re-typing.

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