0
votes

I am trying to create a choropleth map using Folium. I exported a GeoJSON file for London boroughs from an official GIS shapefile. After hours of researching about possible causes, I noticed in my file that the features come up in a different order compared to another GeoJSON file that works, which I assume is the reason for not appearing on the map. Basically the order in mine is something like

"features": [ 
    "geometry": {...}, 
    "properties": {...}, etc  

and the working GeoJSON has

"features": [ 
   "properties": {...},
   "geometry": {...},  

My question is How can I change the order of the features or how to make it render with Folium?

The code for creating the map is as follows:

london = r'london_simple.json' # geojson file
# create a plain London map
london_map = folium.Map(location=[51.5074, 0.1278], zoom_start=10)

london_map.choropleth(
   geo_data = london,
   data = dfl1,
   columns = ['Area_name', 'GLA_Population_Estimate_2017'],
   key_on='feature.properties.Counties_1',
   fill_color = 'YlOrRd',
   fill_opacity = 0.7,
   line_opacity=0.2,
   legend_name='Population size in London'
   )
london_map

I'm working in a jupyter notebook on IBM Watson, if that makes any difference. If I use my geojson file, no choropleth regions appear. If I change to the other file, it works (provided I change the map coordinates to Toronto ([37.7749, -122.4194]).

My code doesn't generate any error, just the plain map focused on London without the choropleth regions.

Link to working geojson

Link to my problematic geojson

2

2 Answers

0
votes

Have you tried this instead?

key_on='feature.properties.Counties_a'

I think the code beginning with E should identify the relevant part of the shapefile.

0
votes

There seem to be a few problems with the JSON file for London-

  1. The coordinate values are faulty. They contain values such as [532946.0999999996, 181894.90000000037] when in reality it should be something like [ -0.042770, 51.531530 ].
  2. There seem to be very few values to draw a polygon of the counties.

Search for an alternative Geojson for London, I found a working one here