0

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?

2
  • 1
    The overlay method was only added in GeoPandas version 0.10.0, maybe you have an older version? (you can check geopandas.__version__) On older versions, you can use the function instead: grid = geopandas.overlay(grid, national_outline, ..) Commented Apr 30, 2023 at 7:30
  • Thanks, Joris. This actually worked when I changed the function specification to the one you state. Do you want to add it as a proper answer and I will then be able to fully close the question? Commented Apr 30, 2023 at 15:01

1 Answer 1

1

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, ..)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.