Now we have a nice choropleth map but it's completely static.
Or (and we will see this later) you can use a custom colormap Instead of using fixed values depending on the data we have, you can use quantile() and tolist() to specify a quantile scale. If you don't want to use the default D3 scale (Folium uses Leaflet that uses D3), you can easily pass your own scale via threshold_scale parameter threshold_scale can be passed to give a different threshold scale.fill_color can be a ColorBrewer palette ( ).It should start with ‘feature’ and be in JavaScript objection notation, so in our case, it is _NIL Instead of using a separate dataframe for our values, we can also use a value already inside our geo_data dataframe columns the columns inside the data dataframe that contains the keys and the values to be mapped.data: the dataframe containing values we want to show in the map (in this case it will be the same as geo_data).geo_data: the geopandas dataframe with the geometries.Now we can use Folium choropleth method to draw our choropleth map lormap ( ), an utility module to deal with colormaps.folium ( ) that makes it easy to visualize data that’s been manipulated in Python on an interactive leaflet map.geopandas ( ) that extends the datatypes used by pandas to allow spatial operations on geometric types.pandas ( ), a high-performance, easy-to-use data structures and data analysis tools for Python.So I spent some time to tweak and play with different options and at the end, I've to say that I'm really happy with the resultsĭuring the process, I discovered some useful tricks and I want to share my findings with all of you, hoping this will save you precious time A heat map is similar but does not use geographic boundariesĪfter experimenting a little with different libraries, I found that Folium ( ) was great for my task Choropleth maps provide an easy way to visualize how a measurement varies across a geographic area or show the level of variability within a region. While working to a geodata analysis project I had the need to quickly and easily create some interactive choropleth maps overlayed to some other raster and vector layersįrom Wikipedia: A choropleth map is a thematic map in which areas are shaded or patterned in proportion to the measurement of the statistical variable being displayed on the map, such as population density or per-capita income.