Spatially explicit models for distance sampling data: density surface modelling in practice

8-12 March 2021, 1600-1800 BST // 1100-1300 EDT // 0800-1000 PDT

This online course will cover how to fit spatial models to distance sampling data (“density surface modelling”) in R. This will include:

  • Brief overview of distance sampling
  • Generalized additive models
  • Fitting, checking and selecting density surface models
  • Predicting abundance
  • Making maps

Examples will be based around a line transect survey of sperm whales in the western Atlantic.


The course will consist of 5 live sessions delivered over videoconference. Between these sessions there will be practical R exercises to complete and to assist with these practicals there will be text-based “office hours”, where participants questions can be addressed. Each videoconference session will include time for lecturing and discussion of practical exercises.


Links in the “Part” column below will take you to the corresponding slides or practicals. These are HTML pages, but you might find it useful to “Print to PDF” for annotation (usually within the Print menu in your browser). Slides are numbered to help orientate yourselves.

For the practicals you need spermwhale.RData which you can download by clicking here, which contains all the R objects you will need (see below for R package requirements).

Practicals are provided as RMarkdown and as HTML pages. If you aren’t familiar with RMarkdown here is a quick introduction from RStudio (you only need to read the first 4 sections to know enough for this course).

Session Part Description
Monday Lecture 1 Distance sampling refresher
  Lecture 1 (PDF) What is a DSM?
    Getting to know the data
  Practical 1 (Rmd) (html) Detection function fitting
  Practical 1 solutions (Rmd) (html)  
Tuesday Lecture 2 Recap/solutions for “Detection function fitting”
  Lecture 2 (PDF) Generalized additive models
  Practical 2 (Rmd) (html) Fitting simple DSMs
  Practical 2 solutions (Rmd) (html)  
Wednesday Lecture 3 Recap/solutions for “Fitting simple DSMs”
  Lecture 3 (PDF) Multiple smooths
    Model selection
  Practical 3 (Rmd) (html) Fitting and selecting more complex models
  Practical 3 solutions (Rmd) (html)  
Thursday Lecture 4 Recap/solutions for “Fitting and selecting more complex models”
  Lecture 4 (PDF) Model checking
  Practical 4 (Rmd) (html) Checking previous models
  Practical 4 solutions (Rmd) (html)  
Friday Lecture 5 Recap/solutions for “Checking previous models”
  Lecture 5 (PDF) Making predictions
    Estimating variance
    Practical advice
  Practical 5 (Rmd) (html) Making predictions, variance estimation, maps
  Practical 5 solutions (Rmd) (html)  

All materials here are available (including the sources for the slides) at this github repository.

R requirements

Please make sure you have the latest version of R on your computer (version 4). You can download this from:

Once R is installed, please run the following line of code:

install.packages(c("rmarkdown", "Distance", "ggplot2", "knitr",
                   "dsm", "patchwork", "plyr"))

to ensure that you have the latest versions of all the R packages you need for the course.

Note that this might take a while depending on your internet connection speed.

Additional resources