Data science is concerned with finding answers to questions on the basis of available data, and communicating that effort. Besides showing the results, this communication involves sharing the data used, but also exposing the path that led to the answers in a comprehensive and reproducible way. It also acknowledges the fact that available data may not be sufficient to answer questions, and that any answers are conditional on the data collection or sampling protocols employed.

This book introduces and explains the concepts underlying spatial data: points, lines, polygons, rasters, coverages, geometry attributes, data cubes, reference systems, as well as higher-level concepts including how attributes relate to geometries and how this affects analysis. The relationship of attributes to geometries is known as support, and changing support also changes the characteristics of attributes. Some data generation processes are continuous in space, and may be observed everywhere. Others are discrete, observed in tesselated containers. In modern spatial data analysis, tesellated methods are often used for all data, extending across the legacy partition into point process, geostatistical and lattice models. It is support (and the understanding of support) that underlies the importance of spatial representation. The book aims at data scientists who want to get a grip on using spatial data in their analysis. To exemplify how to do things, it uses R.

It is often thought that spatial data boils down to having observations’ longitude and latitude in a dataset, and treating these just like any other variable. This carries the risk of missed opportunities and meaningless analyses. For instance,

  • coordinate pairs really are pairs, and lose much of their meaning when treated independently
  • rather than having point locations, observations are often associated with spatial lines, areas, or grid cells
  • spatial distances between observations are often not well represented by straight-line distances, but by great circle distances, distances through networks, or by measuring the effort it takes getting from A to B

We introduce the concepts behind spatial data, coordinate reference systems, spatial analysis, and introduce a number of packages, including sf (Pebesma 2018, E. Pebesma (2020b)), lwgeom (E. Pebesma 2020a), and stars (E. Pebesma 2020c), as well as a number of tidyverse (Wickham 2017) extensions, and a number of spatial analysis packages that can be used with these packages, including gstat (Pebesma and Graeler 2020), spdep (R. Bivand 2019b) and spatstat (Baddeley, Turner, and Rubak 2018).

This work is licensed under the Attribution-NonCommercial-NoDerivatives 4.0 International License.


Baddeley, Adrian, Rolf Turner, and Ege Rubak. 2018. Spatstat: Spatial Point Pattern Analysis, Model- Fitting, Simulation, Tests.

Bivand, Roger. 2019b. Spdep: Spatial Dependence: Weighting Schemes, Statistics.

Pebesma, Edzer. 2018. “Simple Features for R: Standardized Support for Spatial Vector Data.” The R Journal 10 (1): 439–46. doi:10.32614/RJ-2018-009.

Pebesma, Edzer. 2020a. Lwgeom: Bindings to Selected ’Liblwgeom’ Functions for Simple Features.

Pebesma, Edzer. 2020b. Sf: Simple Features for R.

Pebesma, Edzer. 2020c. Stars: Spatiotemporal Arrays, Raster and Vector Data Cubes.

Pebesma, Edzer, and Benedikt Graeler. 2020. Gstat: Spatial and Spatio-Temporal Geostatistical Modelling, Prediction and Simulation.

Wickham, Hadley. 2017. Tidyverse: Easily Install and Load the ’Tidyverse’.