Chapter 21 Spatial Data (including mapping)

21.1 Introduction

Cartographic design principles

Choropleth maps

21.2 Theory and methods

A Gentle Introduction to GIS

21.2.1 Map projections

A rich and complicated topic in and of itself: how can the surface of a sphere be represented in a two dimensional plane without distortion? (Answer: it can’t, but the distortion can be minimized to suit the purpose of the map.)

21.2.2 Geographic references (coordinate reference systems)

Spatial Reference – URL/URI-based references to spatial reference systems, including EPSG and ESRI.

Coordinate Reference Systems – from A Gentle Introduction to GIS

British Columbia’s standard is BC Albers (EPSG:3005)

Coordinate Reference System and Spatial Projection – from Spatial Data in R, part of an Earth Analytics course.

21.3 Canadian geography: shapefiles

Statistics Canada has made available a variety of boundary files.

DataBC has a number of of geographic boundary files available

21.4 R

21.4.1 Spatial Data in R: text books

Roger S. Bivand, Edzer J. Pebesma, and Virgilio Gómez-Rubio (2008) Applied Spatial Data Analysis with R {PDF version of text book}

Robin Lovelace, Jakub Nowosad, and Jannes Muenchow, Geocomputation with R

Edzer Pebesma and Roger Bivand, Spatial Data Science – textbook, work in progress.

Manuel Gimond, Intro to GIS and Spatial Analysis – “compilation of lecture notes for my Introduction to GIS and Spatial Analysis course (ES214)” at Colby College, Maine.

21.4.2 Spatial Data in R: blogposts, tutorials, etc.

twitter thread on “geocomputation in R”:

Aleszu Bajak, 2018-12-20, “How to map point data and polygon shapefiles in R”

Frank Davenport (2012) “Notes from A Recent Spatial R Class I Gave”

Nick Eubank, Merging Spatial Data

Matthias Forkel (2015) Analysis of spatial data in R {PDF version of presentation/lecture slide deck}

Kieran Healy, 2018-12-09, Canada Map

Tomislav Hengl, A Practical Guide to Geostatistical Mapping {PDF ebook available via Lulu}

Jacinta Holloway, raster2data

  • “This repository provides some introductory guidance for working with spatial image files, like rasters, and converting these to dataframes in R in order to perform statistical analyses. Includes an example satellite image and R code.”

Katie Jolly, 2019-08-15, Geographic Data Science in R – presentation at R North 2019 conference.

Arda Kosar, 2018-05-01, A Beginner’s Exploration of Shiny and Leaflet for Interactive Mapping

Robin Lovelace (2014) “R, an Integrated Statistical Programming Environment and GIS” {blog post}

Robin Lovelace, James Cheshire and others, 2015-, Introduction to visualising spatial data in R {or up-to-date version on github, Robinlovelace/Creating-maps-in-R {tutorial}

Sharon Machlis (2016) Create maps in R in 10 (fairly) easy steps, Computerworld (2016-03-01)

Mel Moreno and Mathieu Basille, 2018-10-25, Drawing beautiful maps programmatically with R, sf and ggplot2

Mark Padgham, Geoff Boeing, et al., 2019-08-07, An Introduction to Software Tools, Data, and Services for Geospatial Analysis of Stroke Services, Frontiers in Neurology, 07 August 2019 |

Vivek Patil (2015) Animated choropleths using animation, ggplot2, rCharts, googleVis, and Shiny (2014-01-17)

Francisco Rodriguez-Sanchez, 2013-12-18, Spatial data in R: Using R as a GIS {github version at Pakillo/R-GIS-tutorial}

Dominic Royé, 2018-11-03, Accessing OpenStreetMap data with R

Mithil Shah, 2016-04-18, R and GIS – working with shapefiles

Andrew Tran, 2019, Mapping with R NICAR19 session

21.5 R Packages

21.5.1 {cartography}

github page: cartography

21.5.4 {ggspatial}


CRAN page: [ggspatial: Spatial Data Framework for ggplot2] (

gihub page: A ggplot2 R extension for plotting Spatial objects

21.5.5 {GISTools}


CRAN page: [GISTools: Some further GIS capabilities for R] (


21.5.8 {mapdeck}

“Provides a mechanism to plot an interactive map using ‘Mapbox GL’ (, a javascript library for interactive maps, and ‘’ (, a javascript library which uses ‘WebGL’ for visualising large data sets.”


CRAN: mapdeck: Interactive Maps Using ‘Mapbox GL JS’ and ‘’

{mapdeck} reference


Mapdeck - more than a map – poster presented at rstudio::conf 2020

21.5.9 {sf}


CRAN: sf: Simple Features for R


Timo Grossenbacher, 2019-04-19, Bivariate maps with ggplot2 and sf

21.5.10 {sp}


CRAN: sp: Classes and Methods for Spatial Data

vignettes: Edzer Pebesma and Roger S. Bivand (2005): Classes and Methods for Spatial Data: the sp Package


Edzer Pebesma (2008) Introduction to R and package sp

21.5.11 {tmap}


CRAN: tmap: Thematic Maps

vignettes: tmap in a nutshell

GitHub: tmap


Corentin M. Barbu, 2015-11-06, “tmap R package”

Jakub Nowosad, 2019-10-17, Map coloring: the color scale styles available in the tmap package

21.5.12 {urbnmapr}


Sarah Strochak, How to Create State and County Maps Easily in R