Geopandas and Google Colab issue: Spatial indexes require either `rtree` or `pygeos`

Viewed 3079

I am trying to do an intersection with 2 GeoDataFrame using the gdf.overlay function on Google Colab. Please see the code below

!sudo apt install libspatialindex-dev
!sudo pip3 install rtree
!pip install pygeos

overlap = gpd.overlay(gdf1,gdf2, how='intersection')
overlap.plot(figsize=(10,10), cmap='jet')

and I get the following error message

ImportError: Spatial indexes require either `rtree` or `pygeos`. See installation instructions at https://geopandas.org/install.html

What is causing the issue here?

1 Answers

I had the same issue with running this on colab, it's because of dependencies, follow the same order as suggested in: https://geopandas.org/getting_started/install.html

For me, error gone when I first installed dependencies:

!pip install pandas fiona shapely pyproj rtree

and then:

!pip install geopandas
Related