Three Ways to Plot Choropleth Map Using Python

Burger Wu
Geek Culture
Published in
3 min readApr 5, 2021
Photo by Angela Lo on Unsplash

Choropleth map is an exceptional choice for presenting geospatial data. In this article, we will introduce you to three methods for plotting Choropleth map. Let’s begin.

Github Repo: here

Data Preparation

In order to demonstrate our choropleth map, we have acquired population data for every city and county of Taiwan as our dataset of interest. You can find the dataset in this website. Below is the final dataframe after cleaning and data manipulating. We will later use this dataframe to do out Choropleth plotting.

Get Json

Geojson is a important part of Choropleth map because it records the actual outline of the area of interest. You can find the geojson of Taiwan from here. As for other country or region, you may find useful information by searching the internet.

1. Folium

Folium is a Python library specializing in visualizing geographical data, of course including Choropleth map. This is our first method of plotting Choropleth map. For more information and documentation, please check here.

Below is the code for plotting Choropleth map using Folium.

Below is the result of Choropleth map of Taiwanese administrative division population using Folium.

2. Plotly

Plotly is a Canadian software company, but in this porject, the Plotly we are talking about is an advanced plotting libraries in Python known for interactive plots made by Plotly. You can check out here for more information.

Below is the code for plotting Choropleth map using Plotly.

Below is the result of Choropleth map of Taiwanese administrative division population using Plotly.

3. GeoPandas

Below is the code for plotting Choropleth map using Geopandas.

Below is the result of Choropleth map of Taiwanese administrative division population using Geopandas.

Conclusions

In this project, we create Choropleth map using three different Python libraries, folium, plotly and geopandas.

Folium:

Folium can create professional, interactive maps but it is relatively hard and complicated to build one map. It requires function or tooltip object to further enhance the map.

Plotly:

Plotly can create professional, interactive maps along with some more default functions as well as pre-built styles. It may be a bit more convenient than Folium to create maps with diverse styles.

Geopandas:

Geopandas can create non-interactive maps but it’s relatively fast to build one map. Also, geopandas allows you to work with pandas dataframe with which most Python users are familiar.

All of the three can successfully convey the information we would like to share through Choropleth map, it’s up to you to decide which is the best for you. Also remind yourself, interactive maps should be more memory consuming than normal maps.

There are still a lot of parameters you could try to beautify your map. Other than searching for technical documents, also try to search online to see if anyone else has already created one you would like. You can find the notebook, dataset and other information of this projec in Github Repo.

Reference

  1. Toward Data Science: https://towardsdatascience.com/a-beginners-guide-to-create-a-cloropleth-map-in-python-using-geopandas-and-matplotlib-9cc4175ab630
  2. CSDN : https://blog.csdn.net/u010099080/article/details/104543491
  3. Ministry of Interior: https://www.ris.gov.tw/app/portal/346

--

--

Burger Wu
Geek Culture

Data Science Enthusiast from Taiwan, especially interested in application in Energy Industry & Industry Automation