【问题标题】:Upload Shapefile to PostGis将 Shapefile 上传到 PostGis
【发布时间】:2018-10-26 04:37:23
【问题描述】:

我有一个 shapefile,但我不知道如何使用 Python 3 将它上传到我的 PostGis。

有没有人有我怎么做的例子或想法?

【问题讨论】:

    标签: python-3.x shapefile


    【解决方案1】:

    您可以使用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

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 2018-01-02
      • 2014-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多