无法使用Windows 10上的PGSQL2SHP对每个日期导出ShapeFile
我的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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
注意:
for /l < /code> stephan提到的语法。
半隆被视为分离器,与 space 相同的
SQL语句中的
$ i
应为%i
以替换%i i
的值。;完成
我不知道 - 可能需要。如果将其作为批处理文件中的行执行,则每个
%i
都需要为%% 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.