EL-BID / IADB-education-1

Repo for GitHub's Skills-based volunteering project with the IADB
Other
2 stars 1 forks source link

Create visualizations for travel times to school #8

Closed robcrystalornelas closed 1 year ago

robcrystalornelas commented 1 year ago

Data visualizations for travel time to schools can take the form of heatmaps or other visualizations.

One thing to note is that rather than saving heatmaps or any maps we produce as JPEG or PNG files, we should figure out a way to save them as zoomable maps where the links can be shared.

Claudio9701 commented 1 year ago

This notebook generates static and interactive maps (html) for this brazilian cities, this htmls are served with github pages inside of the same repository: Brasilia Camipiñas Sao Paulo Rio de Janeiro

robcrystalornelas commented 1 year ago

Awesome, thanks so much for these resources @Claudio9701. I'm still running into an error when I try to run up.routing.start_osrm_server('brasil', 'south-america', 'foot')

Do I need to start up a docker container? I'm wondering if it would be most helpful if we schedule a pairing session to discuss.

I also haven't downloaded the latest version of urbanpy and was wondering if that may solve this. The error I get is:

No such file or directory: 'docker'

Claudio9701 commented 1 year ago

Great @robcrystalornelas!

From our conversation a few weeks ago, I realized it is too hard for an example notebook to depend on instantiating docker containers. Thus, I made this example notebook which calculates the distance matrix using python only. This way is easier but slower.

Using the a local OSRM Server built with docker its the fastest way to the calculation. It is possible to use it with the pypi version of urbanpy but in the case of brazil the OSM data is divided by subregions. Sadly, the first urbanpy version can't automatically download the subregion data in these cases (The new one can! at least in linux and macos-based systems 😅). So there are some manual tweaks needed, the steps to make it work are the following:

  1. Download and install docker for your preferred platform
  2. Since Florianopolis is localted inside the "sul" subregion, download the Brazil "Sul" subregion OSM DATA and put it on this location "~/data/osrm/sul-latest.osm.pbf".
  3. Install urbanpy if it is not installed: $ pip install urbanpy
  4. To setup the OSRM server use the following code:
    
    # Server config
    OSRM_COUNTRY = "sul" # subregion name
    OSRM_CONTINENT = "south-america_brazil" # combination of continent_country
    OSRM_PROFILE =  "foot" # other options are 'car' or 'bicycle'

Start server

up.routing.start_osrm_server(OSRM_COUNTRY, OSRM_CONTINENT, OSRM_PROFILE)

Wait for the OSRM server to be running and ready to use (See screenshot below)

This could take around 5 to 10 minutes the first time

time.sleep(20) # Subsequent start times should be between 5 - 20 seconds

Calculate travel times and distances between 2 points

Distance is measured in meters and duration, in seconds

distance, duration = up.routing.osrm_route(origin=point1, destination=point2)

Stop server

up.routing.stop_osrm_server(OSRM_COUNTRY, OSRM_CONTINENT, OSRM_PROFILE)



This is the output of a OSRM server working properly:
![image](https://user-images.githubusercontent.com/24416566/217225164-16ae3ae3-57dc-48e7-a436-0844c47981c3.png)

I've tested the [notebook](https://github.com/Claudio9701/urbanpy-brazil-demo/blob/master/Pop_Access_UrbanPy_Demo_BR.ipynb) mentioned in the [previous comment](https://github.com/github/IADB-education/issues/8#issuecomment-1404032357) and the results are the following:

- No. of resolution 8 hexagons generated: 977
- No. of education facilities downloaded: 44
- Maps:

| ![image](https://user-images.githubusercontent.com/24416566/217228186-385ff601-3334-48f5-bc19-d2f60acce35c.png)  | ![image](https://user-images.githubusercontent.com/24416566/217228029-4bcf3a8e-455a-4ac4-9211-ccdc8a834803.png)  | ![image](https://user-images.githubusercontent.com/24416566/217228094-a8fff84e-f2d1-4848-b337-0465154bb3d1.png)  |
|---|---|---|
| Adm. limits  | Population  | Accessibility  |

- [See the Interactive map](https://claudio9701.github.io/urbanpy-brazil-demo/florianopolis).

Let me know if this helps. Also, I was thinking that 44 is a small number maybe a double check with local sources is needed. Good luck!
robcrystalornelas commented 1 year ago

OK Great, thanks for this help @Claudio9701. I'm going to give it a try over the next couple of days and will let you know how it goes ✨

Claudio9701 commented 1 year ago

Also, I think we can schedule a pairing session for thursday or friday evening (from 18 h onwards in paris time) if it works for you and your team :D

robcrystalornelas commented 1 year ago

Awesome, just added a meeting to our calendars 👍🏻

robcrystalornelas commented 1 year ago

We have completed part of project visualizing travel time to schools