【发布时间】:2018-10-26 04:37:23
【问题描述】:
我有一个 shapefile,但我不知道如何使用 Python 3 将它上传到我的 PostGis。
有没有人有我怎么做的例子或想法?
【问题讨论】:
标签: python-3.x shapefile
我有一个 shapefile,但我不知道如何使用 Python 3 将它上传到我的 PostGis。
有没有人有我怎么做的例子或想法?
【问题讨论】:
标签: python-3.x shapefile
您可以使用subprocess 执行shp2pgslq 命令来获取postgis 的sql 查询。
import subprocess
p = subprocess.Popen(["shp2pgsql", "layer.shp", "schemaName.tableName"], stdout=subprocess.PIPE)
output, err = p.communicate()
然后您可以对您的数据库使用output 查询。
https://postgis.net/docs/using_postgis_dbmanagement.html#shp2pgsql_usage https://docs.python.org/3.7/library/subprocess.html
希望对你有帮助。
【讨论】: