I get an odd error when I run this overlay intersection using geopandas:
grid = grid.overlay(national_outline, how='intersection')
The error states no attribute 'overlay' is available despite both grid
and national_outline
being functioning geopandas dataframes:
Traceback (most recent call last):
File "C:\Users\eoughton\Desktop\Github\ccdr-basic\scripts\wealth.py", line 238, in <module>
create_regional_grid(country)
File "C:\Users\eoughton\Desktop\Github\ccdr-basic\scripts\wealth.py", line 62, in create_regional_grid
grid = grid.overlay(national_outline, how='intersection')
File "C:\Users\eoughton\Anaconda3\envs\ga\lib\site-packages\pandas\core\generic.py", line 5575, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'GeoDataFrame' object has no attribute 'overlay'
I've only found one other similar question here which identified libspatialindex and rtree as potential culprits.
However, I've exported my conda environment from another computer where this works fine, and created it on a new machine which produces this error. Both libspatialindex and rtree are installed. The .yml environment file with all package versions is here.
Any ideas why this would be happening?
The overlay
method was only added in GeoPandas version 0.10.0, so based on the error, you probably have an older version (you can check geopandas.__version__
).
On older versions, you can use the function instead:
grid = geopandas.overlay(grid, national_outline, ..)