A cartogram is a  map in which the geometry of regions is distorted in order to convey the information of an alternate variable. In this example, we are going to draw a map of Africa where the size of each country is distorted proportionally to its population.

First of all, you need to understand what a geospatial object is, and how to plot it with R. See the background map section of the gallery!

Let’s use the maptools library which provide a geospatial object with the Africa’s boundaries. Note that you can get a similar object from a shapefile, or from a geojson file!

We can plot the boundaries using the plot() function:





The geospatial object has a ‘data slot‘: an attached data frame that provides several information for each region. It notably gives the population of each country in 2005. We can thus use the cartogram library to distort the size of each country, proportionally to this column. The new geospatial object we get can be drawn with the same plot function!

See how Nigeria is now bigger?



Of course, it is possible to custom the representation. Since we have a spatial object, all the techniques described in the map, chloropleth and hexbin sections will work here to. Let’s use ggplot2 to add some color, title, legend, background … We now have a nice cartogram chloropleth map of Africa!




Make a search



Leave a Reply

1 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
1 Comment authors
Richard Leyshon Recent comment authors
newest oldest most voted
Notify of
Richard Leyshon
Richard Leyshon

Hi there, great article. I would really appreciate a further breakdown of the requirement to use Tidy when utilising ggplot to customize the cartogram. For example, the join created and why these steps are necessary in customization. Also, can you pass the cartogram to leaflet for interactive renderring? Or perhaps plotly?