How to generate Folium map using GeoDataFrame? How to generate Folium map using GeoDataFrame? json json

How to generate Folium map using GeoDataFrame?


In recent releases of folium, you don't need to convert the GeoDataFrame to geojson, but you can pass it directly. Connecting the population column to color the polygons is still somewhat tricky to get correct:

m = folium.Map()m.choropleth(world, data=world, key_on='feature.properties.name',             columns=['name', 'pop_est'], fill_color='YlOrBr')m


The m.cholopleth() code in @joris's answer is now deprecated. The following code produces the same result using the new folium.Chloropleth() function:

m = folium.Map()folium.Choropleth(world, data=world,                   key_on='feature.properties.name',                  columns=['name', 'pop_est'],                   fill_color='YlOrBr').add_to(m)folium.LayerControl().add_to(m)m