-
Notifications
You must be signed in to change notification settings - Fork 0
COD Services API: Integration with other platforms to visualize results using IPYLeaflet, Overpass API in a Jupyter Notebook
The COD Services API offers the means to integrate the UN OCHA portfolio of Common Operational Datasets with other tools to answer questions.
How many OpenStreetmap Users are active in an area?
To answer the question, the following example uses the Overpass API for Humanitarian OpenStreetMap content with tools such as Anaconda Jupyter Notebook to incorporate widgets and addins such as ipyleaflet for showing results in the map. The COD Services API provides vector tile sources and lookup results for locations.
The approach is three steps:
- Query the COD Services API for areas in the primary location of study, i.e. Senegal
- Query the Overpass API with the given area names returned from the COD Services API query
- Show the results on the map.
# query COD Services api to get area_names for Senegal url = "http://apps.itos.uga.edu/CODV2API/api/v1/themes/cod-ab/lookup/1/SN" response = requests.get(url) dataDict = json.loads(json.dumps(response.json())) print("Locations for study OSM Users:")
The Jupyter Notebook shows the block to run that will parse the results passed in to Overpass to show the results: An adaptation based on a Martijn van Exel python wrapper.
Results which may be formatted are as follows:
The areas to be mapped may run into other queries to check the COD Services API if the vector tiles are available to show results on a map. The vector tiles may be brought into the Jupyter environment using the ipyLeaflet extension with the code as shown in the image:
Using the vector tiles from the COD Services API source makes understanding the data are from the OCHA processes with qualified metadata.
Other visualization outputs may more clearly show the users per area on the map and other contexts.
Helpful resources/Getting Started:
- Installing Anaconda
- Installing ipyLeaflet ipyLeaflet using conda
- Install Overpass in the ipyLeaflet enabled environment (conda prompt: pip install Overpass)
- Enable the ipyleaflet extension: At the conda prompt: jupyter nbextension enable --py --sys-prefix ipyleaflet