useR! 2019 - Toulouse - 2019/07/09

Produce publication ready thematic maps

Standing on the Shoulders of Giants

Initialy based on sp & rgeos…


… and updated to sf with version 2.0.0 (Sep, 2017)

Main Features: Symbologies

Main Features: Transformations

Main Features: Map Layout

Cheat Sheet

Website

Vignette

Alternative Solutions

ggplot2 (Wickham, 2016) + ggspatial (Dunnington, 2018)

  • A general purpose graphic library

tmap (Tennekes, 2018)

  • A mapping library with similar functionalities
  • Uses a different grammar (à la ggplot2)
  • Allows interactive maps

library(sf)
library(cartography)
# path to the geo file embedded in cartography
path <- system.file("gpkg/mtq.gpkg", 
                    package = "cartography")
# import to an sf object
mtq <- st_read(dsn = path, quiet = TRUE)
# Set figure margins
par(mar = c(0,0,1.2,0), bg = "#b5d0d0")
# Plot the choropleth map
choroLayer(
  x = mtq, var = "MED", 
  method = "equal", nclass = 4, 
  col = carto.pal(pal1 = "sand.pal", n1 = 4),
  legend.values.rnd = -2, legend.pos = "left", 
  legend.title.txt = "Median Income\n(in euros)"
) 
# Plot a layout
layoutLayer(
  title="Wealth in Martinique, 2015", 
  author = "T. Giraud, 2019", 
  sources = "Sources: Insee and IGN - 2018", 
  scale = 5, north = TRUE,
  tabtitle = TRUE, frame = FALSE
)



  • osrm: Gets road distances (time) between each municipalities.

  • SpatialPosition: Computes gravitationnal accessibility based on road distances.

  • cartography::getBreaks(): Classifies data

  • cartography::carto.pal(): Uses color palettes from the package

  • cartography::choroLayer(): Plots the choropleth map

  • sf: Provides geodata transformations

  • cartography::propSymbolsLayer(): Plots the proportional symbols

  • cartography::layoutLayer(): Plots the map layout

  • cartography::getPencilLayer(): Transforms polygons to hand-drawn polylines

  • cartography::choroLayer(): Plots the choropleth map




  • spatstat: Computes Kernel Density Estimation

  • tanaka: Plots shaded contour lines

  • cartography::LegendChoro(): Plots legend

  • cartography::layoutLayer(): Plots map layout

  • cartography::choroLayer(): Plots the choropleth map

  • cartography::getBorders(): Extract borders between countries

  • cartography::discLayer(): Plots discontinuities on borders

  • cartography::layoutLayer(): Plots the map layout

Thank You