World Population Cartograms

Oct 12, 2022

Klaus Schulte

In one of my recents projects, I’ve created a world population cartogram.

In such a map, country size represents population. Each one-by-one square stands for 500,000 people. Each country exists of as many squares as needed to represent its population.

About Cartograms

According to Max Roser, founder of OurWorldInData, this is “the map we need if we want to think about how global living conditions are changing”. Because it puts people and populations into the focus of attention, other than geographical maps which represent land area.

World Population 2018, Max Rosner/Our World In Data

To learn about which countries are over- and underrepresented in geographical maps, click the map below created by Lisa Charlotte Muth in datawrapper.

In the same blog, Lisa Charlotte compares different cartogram types and their advantages and disadvantages.

Cartograms in Tableau

Unfortunately, in Tableau you cannot create cartograms by default (other than for example in datawrapper). Nevertheless, when you go to the Tableau Public search, you will find some (contiguous and grid/tile) cartograms available too. Many of them are US focused electoral cartograms. In these, state size represents a state's votes in the electoral college to elect the president of the United States.

And there are other examples. Neil Richards for example created cartograms on Military Spendings and medals won by countries at the Tokyo Olympic Winter Games. I guess Neil created the coordinates manually, so kudos for putting so much work into these great examples!

In all of these examples, the data to build these cartograms has been created outside of Tableau. In Tableau, you'll then plot the data with the shape mark to show units (medals, $1bn spending). Other option is to use it with polygons to have a single area by object (like for states in the electoral cartograms).

World Population Cartogram in Tableau

Data

For my plan to rebuild the Max Roser population cartogram, I was lucky to stumble across this github repository provided by Matt Dzugan, where he provides the data to create it. He also shares further information on how he created the data and how to use it in different tools. A big thank you to Matt - if you're ever going to use this amazing resource, don't forget to pay attribution to Matt!

All I did was to grab these two csv Files:

I then built my data model in Tableau by connecting borders.csv and cells.csv on the numeric code. I also added country metadata to connect my sample data on the Human Development Index.

Symbols

Use the data from the cells table when you want to use shapes/symbols in your map like in these examples for Europe:

To create it in Tableau, just bring in X and Y as a dimension and add the country name on detail or color:

Since there are some overlapping marks (e. g. Holy See within Italy) you might want to use such a field to sort your marks:

maxID=FIXED [CountryCode (cells.csv)]:MAX([F1 (cells.csv)])}-{ FIXED [CountryCode (cells.csv)]:MIN([F1 (cells.csv)])}

This way you can make sure to always have smaller countries on top of the bigger ones in case of overlapping marks.

Polygons

If you want to create the population map with polygons, you have to use the borders.csv file.

Since we cannot add labels to the polygon mark, you have to use the X and Y coordinates as measures to being able to average them on a second axis. On the second axis, you can then add labels to your preference.

First Axis
Second Axis

Again, create a maxID field similar to the one described for the cells file to sort your polygons accordingly.

Map Layers

Working with the data like described requires manual adjustments of the size of your visual to have the proportions fit. Otherwise it might look squeezed or stretched like in this example.

Also, filtering for example on regions won't work, since the proportions you've figured out only fit for that specific view.

You won't face this problem when working with the map layers feature. Map layers also come with more flexibility to label your map on as many axes as needed.

To not run into issues with the default mercator projection in Tableau, you first have to normalize the coordinates. Therefore it needs the maximum values of X and Y:

  • X_max={MAX([X])}
  • Y_max={MAX([Y])}

Subsequently, you can use these values to normalize your data:

  • X_norm=[X]/MAX([X_max],[Y_max])
  • Y_norm=[Y]/MAX([X_max],[Y_max])

Then, create the geometry using your normalized coordinates:

geometry_borders=MAKEPOINT([Y_norm],[X_norm])

This way, all coordinates are displayed at (artificial) longitudes and latitudes between 0 and 1. Just double-click the geometry field you've created and build that view with the polygon mark type.

That's it!

Wrap Up

Cartograms are a great way to bring data on a map and they are fun to create in Tableau. A world population cartogram in specific is "the map we need if we want to think about how global living conditions are changing", to bring up this quote from Max Roser again.

However, an important limitation of their usage is that the underlying data is kind of hard to create. There is no simple algorithm available (like Matt describes on his git). That's why there is a latent danger that the underlying population figures are outdated (Matt's data is based on 2018 population figures).

Keep that in mind when working with this data!

Again, thanks to Max Rosner for the inspiration and to Matt Dzugan for providing such a great resource.

You can find my example workbook on Tableau Public.

If you’ve found this useful, leave a comment below or reach out to me on Social!