edgi-govdata-archiving / ECHO-Sunrise

An Environmental Enforcement Watch partnership with Sunrise Boston hubs
https://colab.research.google.com/github/edgi-govdata-archiving/ECHO-Sunrise/blob/main/ECHO-Sunrise.ipynb
GNU General Public License v3.0
1 stars 2 forks source link

solution for installing rtree #10

Open ericnost opened 4 years ago

ericnost commented 4 years ago

Unfortunately, it appears we have to restart the user's runtime in order for the notebook to work. That's because restarting the runtime will index a key package - rtree - that we need in order to perform a spatial join between facilities and the unit (town, county, congressional district) they're interested in analyzing. But there has to be a better way than this!

# Import geospatial code libraries
import os
def restart_runtime():
  os.kill(os.getpid(), 9)
!apt update  &>/dev/null;
!apt install gdal-bin python-gdal python3-gdal  &>/dev/null;
!apt install python3-rtree  &>/dev/null;
restart_runtime() # Necessary to install the above ^^^ https://stackoverflow.com/questions/57831187/need-to-restart-runtime-before-import-an-installed-package-in-colab
ericnost commented 4 years ago

The spatial join itself is really important because for some geographies (towns) we can't do an attribute join. Plus, in doing a spatial join, we avoid mis-geocoded facilities.