Spatial-r: Tutorials on spatial data analysis in R
Introduction
This is a collection of tutorials on how to handle spatial data in R. The tutorials target students and scientists in ecology with previous knowledge of the R software.
The core tutorial was developed for a two half-day workshop, but you can follow the tutorials at your own pace.
In these tutorials, we characterize the habitat of otter that were observed in 2021 around Montpellier, France. This small toy case study is not relevant ecologically but provides a good opportunity to tackle multiple challenges with handling and collecting spatial data.
Workshop program
- Introduction to GIS: vectors vs rasters, coordinate reference system (CRS), R as a GIS tool
Half day 1: Vectors
- Points: Transform otter field observations as spatial points
- Lines: Calculate distance from points to nearest lines (river networks)
- Polygons: Characterize land cover using spatial polygons.
Half day 2: Rasters
- raster: Discover what is a raster and get the elevation profile from field observation
- multi layer: Track monthly climate information at the field sites.
Other tutorials
- Toydata: how to get data from GBIF, IGN and CHELSA to create the toy dataset for the workshop.
To be created:
- mapview
- mapsf
- tmap
- tutoE1 : POLYGON: calculate convex hull, simplify geometries, aggregate, union, etc… spatial influence
- tutoE2 : get data from WMS or WFS
- tutoE3 : spatial autocorrelation - how to measure it, what to do about it? spatial regression model, local regression
- tutoE4 : Krigging and interpolation
- tutoE5 : remote sensing, landsat and modis
- tutoE6 : GoogleEarthEngine, what it is and how to use it (mostly out of R)
R packages
The tutorials rely mostly on terra R-package as it was specifically developed to tackle challenges faced by ecologists, agronomists and biologists when using spatial data.
R has an exceptional diversity of users and packages, and this is especially true with the dynamic community in spatial analysis. Another popular package for handling spatial data is sf (and stars).
Other resources
These tutorials were inspired by brilliant online ressources, thanks to all of them:
- Hijman R. et al. Spatial Data Science with R and “terra”
- Pebesma and Bivand Spatial Data Science: With Applications in R
- Moraga P. (2023)Spatial Statistics for Data Science: Theory and Practice with R
- Lovelace, Nowosad, and Muenchow (2025) Geocomputation with R
- Gimond M. (2025) Intro to GIS and Spatial Analysis
- Slingsby J. (2025) A minimal introduction to GIS in R
- Giraud, T. et Pecout, H. (2025). Géomatique et cartographie avec R [fr]