A non-contiguous cartogram is a cartogram, where geographical regions are scaled so that their surface areas represent some data value, such as population, while their original shapes and approximate locations are retained. Compare this with the contiguous cartogram where areas are considerably distorted (see book pages 154–155). Here we will walk through the process of making non-contiguous cartograms using R with RStudio:
To use the package, first install it and its dependencies (if they aren't installed already) in the RStudio console.
You could manipulate the geodata and do the data joins directly in R, but it might in many cases be easier to use a Shapefile with the data prepared in QGIS (read how to use the Joins feature here). For this example we have prepared a Shapefile with the Nordic and Baltic countries and numbers of Bachelor students by NUTS2 regions in 2016, using data from Eurostat. Below the shapefile is displayed in QGIS. You can download the prepared Shapefile here: nuts_bachelors.zip
The NUTS regions can be downloaded in different formats and for different scales at ec.europa.eu/eurostat/web/gisco/geodata/reference-data/administrative-units-statistical-units/nuts.
Make sure that the numerical data field is in decimal numbers (Check that the field is marked Real in QGIS under Layer properties > source fields). The package also supports the creation of contiguous and Dorling cartograms. Note that unlike choropleth maps, this chart type should not be used with percentages or other relative numbers!
# Import packages
# Read shapefile "nuts_bachelors.shp"
nordbalt_nuts2 <- readOGR(dsn = "/myDataFolder/", layer = "nuts_bachelors")
# Assign a projection (EPSG:3034 ETRS89 / LCC Europe, preferred for small-scale maps of Europe)
nordbalt_nuts2 <- spTransform(nordbalt_nuts2, CRS("+init=epsg:3034"))
# Create the non-contiguous cartogram
# "val2016" is the data column name, 0.3 a scale factor
# inplace if TRUE, each polygon is modified in its original place, if FALSE multi-polygons are centered on their initial centroid
nordbalt_nuts2_ncont <- cartogram_ncont(nordbalt_nuts2, "val2016", 0.3, inplace=FALSE)
# Plot the cartogram. The first two functions tm_shape and tm_borders create a background map with blue borders
# tm_polygons draws the cartogram shapes and also defines the data key and color scale breaks (style="jenks"), see help for tm_polygons for options
# for a monochrome cartogram, use tm_polygons("blue")
tm_shape(nordbalt_nuts2) + tm_borders(col="slateblue1") + tm_shape(nordbalt_nuts2_ncont) + tm_polygons("val2016", style = "jenks") + tm_layout(frame = FALSE)
# Create and plot a Dorling cartogram
nordbalt_nuts2_dorling <- cartogram_dorling(nordbalt_nuts2, "val2016", 1)
tm_shape(nordbalt_nuts2) + tm_borders(col="slateblue1") + tm_shape(nordbalt_nuts2_dorling) + tm_polygons("val2016", style = "jenks") + tm_layout(frame = FALSE)
The graphics generated by R can easily be exported to image or vector formats for further editing from the export tab in the "Plot" window. Here’s the non-contiguous and Dorling cartograms side by side as plotted by R.
Note some problematic overlapping regions in Denmark and Finland – in many cases a Dorling cartogram will be both more readable and visually pleasing. A non-contiguous cartogram works best, if the geographical regions are quite regular in shape and size.