Creating Cartograms using QGIS 2.18

Cartograms

First a confession, I don’t like cartograms, at least not the kind where complex boundaries are warped sometimes beyond recognition. However they do have their place and where there aren’t the extremes in the data a cartogram can be a great data visualisation. It is outliers or extreme values that cause the maps to be distorted beyond usable recognition, and therefore look bad (see below).

Cartogram PaullHennig2016WorldMap.OAha.CC-BY-4.0
By John Paull and Benjamin Hennig (http://orgprints.org/30187/) [CC BY 3.0 (http://creativecommons.org/licenses/by/3.0)], via Wikimedia Commons
Anyway, if your data isn’t going to produce a map like this then you can use the Cartogram plugin in QGIS. This allows you to quickly turn your map into one that removes the misrepresentation of small areas hiding large values.

The Cartogram Plugin

To start creating your Cartogram you will need to add in the Cartogram plugin using the Manage and Install Plugins interface:

Installing QGIS plugins

Search for Cartogram, once installed you should see it in your list of plugins:

Installing the Cartogram Plugin

The Data

We are going to use the London Boroughs for this exercise which we are going to scale by the number of people that voted in the EU Referendum.

The data can be downloaded here in GeoPackage format:

LondonBoroughEURef.gpkg

The Method

The plugin makes this all super simple, just start the plugin by clicking on the Vector menu at the top of the screen then Cartogram and Create Cartogram:

Opening the Cartogram plugin

A very simple interface opens where you select the data you want and the attribute you want to scale it by:

Cartogram plugin options

In this example select the LondonBoroughEURef as the Input layer and then the Votes as the Area field.

Iterations

Before you click OK it asks you how many iterations to perform. The default is 5 and this is about right. After this the difference you get is increasingly marginal, with the difference between 10 and 15 iterations imperceptible in most areas.

Base data for Cartogram of London
Base Data
1 Iteration Cartogram of London
1 Iteration
2 Iteration Cartogram of London
2 Iterations
3 Iteration Cartogram of London
3 Iterations
4 Iteration Cartogram of London
4 Iterations
5 Iteration Cartogram of London
5 Iterations
10 Iteration Cartogram of London
10 Iterations

You might be able to see that there isn’t much difference between the change from 4 to 5 iterations and 5 to 10 iterations. However there is a much bigger wait for creating a 10 iteration cartogram than there is for a 5 iteration one. All these images have been combined here with the darkest being 10 iterations and the lightest the original London Boroughs:

Multi layered Cartogram of London
London Borough Cartograms: Each borough is scaled by the number of votes cast in the EU Referendum of 2016. The darker the line the more iterations run by the Cartogram plugin in QGIS: 0, 1, 2, 3, 4, 5, 10.

IMPORTANT NOTE: Each time you run the Cartogram Plugin it creates a new virtual layer called Cartogram. You will need to save this if you want to do anything with it, or not loose it if you close QGIS without saving.

Final Tips and Tricks

If you want to make a cartogram out of data that has got outliers or extreme values there are few things you can do to prevent the distortion affecting your the usability of the map.

Animation:

We have seen that the plugin will provide you with intermediate steps between the base data and the final number of iterations you choose. By generating a map for each of the intermediate numbers of iterations you can create a series that can be animated. Just use the Save as Image… option from the Project menu to create a .png file for each one:

Save as Image in QGIS Project menu

You can then use your favourite animated GIF maker on the internet (just google it) or put it into any movie maker package you have access to. The result will show people how the areas have changed and explain areas where the warping makes them unrecognisable:

Animated Cartogram of London
Animated GIF of the London Boroughs. The map shows most voters are in the central boroughs except the City of London which has the least.

Tone down the effect

There was a very interesting paper at the GISRUK 2017 conference by Richard Harris, Chris Brunsdon, Martin Charlton and David Manley:

Tackling the Curse of Cartograms: addressing misrepresentation due
to invisibility and to distortion

In it they describe a few ways that will help mitigate the problems of extreme cartograms. However you may need to use a different method from the cartogram plugin to achieve the desired effect.