Get folium data in right format for choropleth map

Created on Monday 2 November 2020, 13:30

Back to task list
  • ID
  • Project
    Metabolism of Cities
  • Status
  • Priority
  • Type
    Programming work
  • Assigned to
    Paul Hoekman
  • Subscribers
    Guus Hoekman
    Paul Hoekman

You are not logged in

Log In Register

Please join us and let's build things, together!


In order to make a choropleth map with folium the data needs to be in a specific format.

The example from there:

url = ''
state_geo = f'{url}/us-states.json'
state_unemployment = f'{url}/US_Unemployment_Oct2012.csv'
state_data = pd.read_csv(state_unemployment)

The state_geo part is fine, that's just a geojson like we already have.

They use pandas to read the csv of the data. That's a very simple CSV.

Later on the map is generated like this:

columns=['State', 'Unemployment'],
legend_name='Unemployment Rate (%)'

So the key parts for this work is columns (which defines which columns are taken into consideration) and key_on (which is the place where the geojson features match the first column of the dataset).

They started with CSV so used pandas, but I don't think that's necessary. We just need the same output.

Discussion and updates

New task was created

Task was assigned to Paul Hoekman

Status change: Open → In Progress

The Folium structure is not idea with our current data format and I am suggesting another format. I have set up a "zooming in" map system in which the geojsons for a certain level is created, and I am providing values (quantities, for the choropleth), as well as links that allow for zooming in. When the link is clicked, the system will load the next depth level (e.g. from postal codes to neighborhoods, or from neighborhood to building level), but only for that particular item selected. None of this is properly done in js; instead I am providing the values printed on the page so that you can pick this up Guus and format the js accordingly.

Here are two maps: Melbourne and Brussels. All of this is done in map.html

Status change: In Progress → Completed