我正在尝试实现这个问题的答案: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发布于 2015-11-07 03:53:37
我认为出现这个错误是因为您需要使用SQLite SQLite方言编译您的SQL驱动程序。请参阅:http://www.gdal.org/ogr_sql_sqlite.html
至于更新和编译gdal,这可能很烦人。您运行的是什么操作系统?
https://stackoverflow.com/questions/32791457
复制相似问题