Python geopandas overlay()函数在QGIS中不起作用
我需要通过QGIS中的geopandas找到GeoDataFrame与其自身的交点。该代码在Anaconda环境中运行良好,但在QGIS python中失败 Shapefile可从以下链接获得: 代码如下:Python geopandas overlay()函数在QGIS中不起作用,python,python-3.x,qgis,geopandas,Python,Python 3.x,Qgis,Geopandas,我需要通过QGIS中的geopandas找到GeoDataFrame与其自身的交点。该代码在Anaconda环境中运行良好,但在QGIS python中失败 Shapefile可从以下链接获得: 代码如下: df1 = gpd.GeoDataFrame.from_file("C:\\QGIS_ShapeFile1\\qgis\\laneGroup.shp") intersection_gdf = overlay(df1, df1, how='intersection') 在QGIS中,出现以
df1 = gpd.GeoDataFrame.from_file("C:\\QGIS_ShapeFile1\\qgis\\laneGroup.shp")
intersection_gdf = overlay(df1, df1, how='intersection')
在QGIS中,出现以下错误:
An error has occurred while executing Python code:
AttributeError: 'NoneType' object has no attribute 'intersection'
Traceback (most recent call last):
File"C:/Users/sn43673/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ad_qgis\shapefile_validator.py", line 318, in errorInShapeFile
intersection_gdf = overlay(df1, df2, how='intersection')File "C:\PROGRA~1\QGIS3~1.6\apps\Python37\lib\site-packages\geopandas\tools\overlay.py", line 391, in overlay
File "C:\PROGRA~1\QGIS3~1.6\apps\Python37\lib\site-packages\geopandas\tools\overlay.py", line 216, in _overlay_intersection
for k in j:
File "C:\PROGRA~1\QGIS3~1.6\apps\Python37\lib\site-packages\pandas\core\series.py", line 4042, in apply
mapped = lib.map_infer(values, f, convert=convert_dtype)
File "pandas\_libs\lib.pyx", line 2228, in pandas._libs.lib.map_infer
File "C:\PROGRA~1\QGIS3~1.6\apps\Python37\lib\site-packages\geopandas\tools\overlay.py", line 216, in
for k in j:
AttributeError: 'NoneType' object has no attribute 'intersection'
我最近遇到了这个错误。这是由于RTree包中的DLL问题造成的。
您应该尝试替换libspatialindex.dll文件。您能提供一个小的可复制代码示例吗?@joris我已在上述描述中添加了形状文件。您可以将其与上述代码一起使用。谢谢。您在这两种环境中使用的GeoPandas版本是什么?(您可以使用
geopandas.\uuuuu version\uuuuuuu
)对我来说,这适用于geopandas 0.5.1和0.6.0。我使用的是0.6.0。你在哪里查到的,关于巨蟒的?它对巨蟒很有效,但对QGIS无效谢谢你,费兹。这确实奏效了。我替换了anaconda的dll文件。