Spatial-r: Tutorials on spatial data analysis in R

Author
Affiliation

Romain Frelat

Published

November 4, 2025

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.

TipThe ecologist mind

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

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: