Thematic Cartography

Create and integrate maps in your R workflow. This package allows various cartographic representations such as proportional symbols, chroropleth, typology, flows or discontinuities maps. It also offers several features enhancing the graphic presentation of maps like cartographic palettes, layout elements (scale, north arrow, title...), labels, legends or access to some cartographic APIs. See Giraud and Lambert (2017) .

This package allows various cartographic representations such as proportional symbols, chroropleth, typology, flows or discontinuities. In addition, it also proposes some useful features like cartographic palettes, layout (scale, north arrow, title...), labels, legends or access to cartographic API to ease the graphic presentation of maps.

cartography uses R base graphics to map spatial information.

The vignette contains commented scripts on how to build various types of maps with cartography

vignette(topic = "cartography")

Demo codes in the R graph Gallery (EN)
Create and integrate maps in your R workflow with the cartography package (EN)
Cartographie avec R : le package cartography (FR)
R pour les cartographes (FR)
Comment faire un carton avec R? (FR - How to build inset maps)
Tutoriel - Cartographie avec R (FR)
Cartographie et traitement de l’information géographique avec R (FR)
R pour les cartographes : le package cartography (FR)

  • Development version on GitHub
  • Stable version on CRAN
  • You can access the code used to create the cartographic mix here.

  • The following script creates a map of symbols that are proportional to values of a first variable and colored to reflect the discretization of a second variable.

# Load data
# set margins
opar <- par(mar = c(0,0,1.2,0))
# Compute the compound annual growth rate
nuts2.df$cagr <- (((nuts2.df$pop2008 / nuts2.df$pop1999)^(1/9)) - 1) * 100
# Plot a layer with the extent of the EU28 countries with only a background color
plot(nuts0.spdf, border = NA, col = NA, bg = "#A6CAE0")
# Plot non european space
plot(world.spdf, col  = "#E3DEBF", border=NA, add=TRUE)
# Plot Nuts2 regions
plot(nuts2.spdf, col = "grey60",border = "white", lwd=0.4, add=TRUE)
# Set a custom color palette
cols <- carto.pal(pal1 = "blue.pal", n1 = 2, pal2 = "red.pal", n2 = 4)
# Plot symbols with choropleth coloration
propSymbolsChoroLayer(spdf = nuts2.spdf, 
                      df = nuts2.df, 
                      var = "pop2008", #  field in df to plot the symbols sizes
                      inches = 0.1, # set the symbols sizes
                      var2 = "cagr", #  field in df to plot the colors
                      col = cols, # symbols colors
                      breaks = c(-2.43,-1,0,0.5,1,2,3.1), # breaks
                      border = "grey50",  # border colors of the symbols
                      lwd = 0.75, # symbols width
                      legend.var.pos = "topright", # legend position
                      legend.var.values.rnd = -3, # legend value 
                      legend.var.title.txt = "Total Population", # size legend title
             = "e", # legend type
                      legend.var2.pos = "right", # legend position
                      legend.var2.title.txt = "Compound Annual\nGrowth Rate") # legend title
# layout
layoutLayer(title = "Demographic trends, 1999-2008", coltitle = "black",
            sources = "Eurostat, 2011", scale = NULL,
            author = "cartography", frame ="", col = NA)

One can contribute to the package through pull requests and report issues or ask questions here.


cartography version 1.4.9000 (Release date:)

Major changes:

  • Addition of the hexagonal regular grid in getGridLayer.
  • Addition of barscale function to plot a custom scalebar.
  • Addition of north function to plot a custom north (or south) arrow.

Minor changes:

  • small fix on the msd method (breaks order) in getBreaks function.
  • more precise sources for datasets
  • renaming twincities data frame to twincities.df
  • small fix for ids in getGridLayer

cartography version 1.4.0 (Release date: 2016-08-25)

Major changes:

  • Introduce getOuterBorders that allows to build borders (as getBorders) between non-contiguous polygons.
  • Addition of the theme parameter in layoutLayer to set col and coltitle according to a cartographic palette.
  • discretization function become getBreaks.
  • A new discretisation based on mean and standard deviation is added to getBreaks.
  • Addition of colNA parameter in choro* and typo* function to set a color for NA values.
  • k parameter in prop* function is now defunct, using k will stop the function.

Minor changes:

  • As it was a heavy import, SpatialPosition package is back to suggested packages.
  • As Jenks and Fisher-Jenks algorithms are based on the same principle and give quite similar results but Fisher-Jenks is much faster, "fisher-jenks" method replaces "jenks" in getBreaks methods.
  • In most function, if df is missing then spdf@data is used instead.
  • Introduce function that gives the list of the cartographic palettes.
  • Addition of two qualitatives color palettes ("pastel.pal"" and "multi.pal").

cartography version 1.3 (Release date: 2016-06-07)

Major changes:

  • Introduce the smoothLayer function, this function computes smoothed maps of potentials. It uses quickStewart from SpatialPosition package.
  • Most of previously suggested packages are now imported.

Minor changes:

  • Introduce the legend.*.values.order parameter in typoLayer, propSymbolsTypoLayer and gradLinkTypoLayer. This parameter allows to order modalities in the legend and eases the color assignement.
  • Change min value in prop*Layer legends.
  • Suppress zero values in propSymb*Layer.
  • getGridLayer is faster.
  • getLinkLayer is faster.
  • getBorders is faster.

cartography version 1.2 (Release date: 2016-02-11)

Major changes:

  • The OpenStreetMap package used to display OpenStreetMap tiles has been replaced by the rosm package. rosm installation is lighter and easier (no Java dependency).
  • The k parameter is deprecated in propSymbolsLayer, propSymbolsTypoLayer and propSymbolsChoroLayer. The inches parameter is to be used instead. This modification allows to compare proportionnal symbols maps.

Minor changes:

  • Introduce the getFigDim function that helps to find output figure dimension that fit a Spatial object dimension ratio.
  • The discLayer function now returns a (invisible) SpatialLinesDataFrame of discontinuities.
  • NAs are better managed in choroLayer.
  • The graticule.spdf SpatialLinesDataFrame has been expanded.
  • The size of the title box in layoutLayer is fixed to 1.2 lines height.

cartography version 1.1 (Release date: 2015-11-18)

Major changes:

  • Correction of the proportionnal symbols legends (square, bar, circle, triangle). The previous version was incorrect (size proportionnal to radii and not surfaces).
  • Add a gradLinkTypoLayer function to plot a layer of colored and graduated links.

Minor changes:

  • choroLayer: small correction to allow to plot variable named "x" or "y".
  • vignette: correct the name entry, incorrectly named "SpatialPosition"", to "cartography".
  • Update of the figure in the README file.
  • Darker, and more visible, south and north arrows.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


2.0.1 by Timothée Giraud, a month ago

Report a bug at

Browse source code at

Authors: Timothée Giraud [cre, aut], Nicolas Lambert [aut], Ian Fellows [cph] (no overlap algorithm for labels, from wordcloud package)

Documentation:   PDF Manual  

Task views: Analysis of Spatial Data

GPL-3 license

Imports classInt, stats, graphics, methods, rgeos, rosm, raster, Rcpp

Depends on sp, sf

Suggests SpatialPosition, knitr, rmarkdown, rgdal

Linking to Rcpp

Suggested by MTA, SpatialPosition, osrm, rosm.

See at CRAN