【问题标题】:Python OSGEO/GDAL ST_Intersection errorPython OSGEO/GDAL ST_Intersection 错误
【发布时间】:2015-11-07 03:53:37
【问题描述】:

我正在尝试实现这个问题的答案: https://gis.stackexchange.com/questions/119374/intersect-shapefiles-using-shapely

但我得到了错误:

RuntimeError:使用了未定义的函数“ST_Intersection”。

这里是代码。它在 layer = ogr_ds.ExecuteSQL(SQL, dialect='SQLITE') 行上崩溃。我尝试更新 GDAL 库,但遇到了 pip vcvarsall.bat 问题(也非常令人沮丧)。非常感谢任何帮助!

from osgeo import ogr
ogr.UseExceptions()
ogr_ds = ogr.Open(r'D:\inputs', True) 
SQL = """\
SELECT ST_Intersection(A.geometry, B.geometry) AS geometry, A.*, B.*
FROM stops A, zones B
WHERE ST_Intersects(A.geometry, B.geometry);
"""
layer = ogr_ds.ExecuteSQL(SQL, dialect='SQLITE')
# copy result back to datasource as a new shapefile
layer2 = ogr_ds.CopyLayer(layer, 'result')
# save, close
layer = layer2 = ogr_ds = None

【问题讨论】:

    标签: python gdal osgeo


    【解决方案1】:

    我认为出现错误是因为您需要使用 SQLite SQL 方言编译 SQLite 驱动程序。见:http://www.gdal.org/ogr_sql_sqlite.html

    至于更新和编译 gdal,那可能很烦人。你运行的是什么操作系统?

    【讨论】:

    • 欢迎来到 Stack Overflow!虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。见How do I write a good answer
    猜你喜欢
    • 1970-01-01
    • 2020-03-13
    • 1970-01-01
    • 1970-01-01
    • 2021-06-09
    • 1970-01-01
    • 1970-01-01
    • 2012-02-24
    • 2018-09-24
    相关资源
    最近更新 更多