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 separately
  • 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 to get 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 2018c, Pebesma (2018b)), lwgeom (Pebesma 2018a), and stars (Pebesma 2018d), 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 2019), spdep (Bivand 2018b) and spatstat (Baddeley, Turner, and Rubak 2018).

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


Pebesma, Edzer. 2018c. “Simple Features for R: Standardized Support for Spatial Vector Data.” The R Journal 10 (1): 439–46.

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

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

Pebesma, Edzer. 2018d. Stars: Scalable, Spatiotemporal Tidy Arrays: Raster and Vector Datacubes.

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

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

Bivand, Roger. 2018b. Spdep: Spatial Dependence: Weighting Schemes, Statistics and Models.

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