I am unable to complete spatial joins as my code fails. I have installed all the Geopandas and all its dependencies through pip as it was the only way for Geopandas to work on my PC. Then to run the geopandas.sjoin() command, I installed and imported Rtree (see below). However when I run the command an error comes up saying Rtree is still required. I tried installing both from pip and conda and neither have given me any success. Please let me know if you have any tips/ideas on how I can resolve this.
import rtree
import sys
import pygeos
modulename = 'rtree'
if modulename not in sys.modules:
print('You have not imported the {} module'.format(modulename))
else:
print('Correctly imported')
Output - "Correctly Imported"
admin_area_solar_nodes = gpd.sjoin(gdf, switz_admin1, how= 'inner', op='intersects')
Error:
ImportError: Spatial indexes require either `rtree` or `pygeos`. See installation instructions at https://geopandas.org/install.html
Thanks :)