I have a dataframe with some countries and variables and I would like to produce a choropleth map with folium
, using a geojson file for the entire world. I have a problem with folium
assigning maximum value on a color scale to countries that are not present in my dataframe. Minimum exaple below:
import random
import pandas as pd
import folium
import json
map_data = pd.DataFrame({
'A3':['POL', 'CZE', 'SVK', 'HUN', 'AUT'],
'value':random.sample(range(10), 5)
})
m = folium.Map(
location = [50, 15],
zoom_start = 4
)
m.choropleth(
geo_data = 'https://github.com/simonepri/geo-maps/releases/download/v0.6.0/countries-land-10km.geo.json',
data = map_data,
columns = ['A3', 'value'],
key_on = 'feature.properties.A3',
fill_color = 'YlOrRd'
)
My question is the following: How can I tell folium
to assign a specific color (e.g., gray or transparent) to missing countries (i.e., those present in json file but not in map_data
), instead of coloring them as a maximum value for given variable (which is a strange behavior)?