0

I am trying to conduct an inner spatial join using Geopandas, where both points and poly are Geodataframes.

instersection = gpd.sjoin(points, poly, how='inner')

However it is throwing up the error of: Spatial indexes require either `rtree` or `pygeos`

I am aware it is do with not having installed libspatialindex-dev (see libspatialindex and Rtree on python), but none of the sudo apt install ... method works on Jupyter.

How am I able to install it on Jupyter notebook?

Talha Tayyab
  • 8,111
  • 25
  • 27
  • 44
Victoria S
  • 90
  • 7
  • 1
    you can install geopandas, jupyter, and rtree at the same time with conda in a way that will ensure they're all set up to work together. see this guide on installation: https://stackoverflow.com/a/72251100/3888719 – Michael Delgado May 24 '22 at 17:26
  • note that using conda to install these compiled dependencies does not require you to be root, as they will be installed within your conda dir. – Michael Delgado May 24 '22 at 17:32

1 Answers1

1

If you are using Google Colab notebook you can find this link to be helpful:

https://colab.research.google.com/drive/1N7i9zmOwVcUzd4eHWZux4p_WTBMZHi8C

I ran the above notebook and was able to successfully install rtree.

While this may be helpful as well:

On your Jupyter cell run this:

!apt-get install -y libspatialindex-dev
Talha Tayyab
  • 8,111
  • 25
  • 27
  • 44
  • I tried running your version of ```apt-get``` but is throwing me errors saying ```E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?``` – Victoria S May 24 '22 at 17:26
  • You do not have permission.. may be you need admin rights.. please check. – Talha Tayyab May 24 '22 at 17:40