Sandip Nepal
Sandip Nepal

Reputation: 94

geopandas overlay() function not working in QGIS

I need to find the intersection of a GeoDataFrame with itself through geopandas in QGIS. The code works perfectly in the Anaconda environment but it fails in the QGIS python.

Shapefile is available at below link: https://drive.google.com/file/d/1DQqg7Cf6AokyadkmOE8Y6k41tqDMXdmS/view?usp=drivesdk

Below is the code:

df1 = gpd.GeoDataFrame.from_file("C:\\QGIS_ShapeFile1\\qgis\\laneGroup.shp")
intersection_gdf = overlay(df1, df1, how='intersection')

In QGIS, the following error occurs:

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'

Upvotes: 1

Views: 424

Answers (1)

Faiz Kidwai
Faiz Kidwai

Reputation: 475

I faced this error recently. It was due to DLL issue in RTree package. You should try replacing libspatialindex.dll file.

Upvotes: 1

Related Questions