Last updated on 20210330
by Edzer Pebesma
This task view aims at presenting R packages that are useful for
the analysis of spatiotemporal data.
Please let the
maintainer know if
something is inaccurate or missing.
The following people contributed to this task view: Roger Bivand, Achim
Zeileis, Michael Sumner, Ping Yang.
Although one could argue that all data are spatiotemporal, as they
must have been taken somewhere and at some point in time, in
many cases the spatial locations or times of observation are not
registered, and irrelevant to the purpose of the study. Here,
we will address the cases where both location and time
of observation are registered, and relevant for the analysis of
the data. The Spatial and TimeSeries
task views shed light on spatial, and temporal data handling and
analysis, individually.
Representing data
 In long tables:
In some cases, spatiotemporal data can be held in tables
(
data.frame
objects), with longitude, latitude and
time as three of the columns, or an identifier for a location
or region and time as columns. For instance, data sets in
package plm for linear panel models have repeated
observations for observational units, where these units often
refer to spatial areas (countries, states) by an index. This index
(a name, or number) can be matched to the spatial coordinates
(polygons) of the corresponding area, an example of this is given
by Pebesma (2012, Journal of Statistical Software). As these
data sets usually contain more than one attribute, to hold the
data in a twodimensional table a long table form is
chosen, where each record contains the index of the observational
unit, observation time, and all attributes.
 In timewide tables:
When a single attribute is considered, another layout is that
of the timewide table, where each observational
unit forms a record and each column an observation time.
googleVis lets you analyze such data in a way similar to
gapminder (see links).
 In spacewide tables:
An example of a spacewide table is the Irish wind data set,
obtained by
data(wind)
in package gstat.
It has time series as different columns, each column representing
one location (weather station). The stConstruct
function in package spacetime accepts data in long,
timewide or spacewide tables.
 Generic classes:
Formal classes for spatiotemporal data in R are provided by
the spacetime package, which offers S4 classes for
full spacetime grids (every observational unit contains an
observation for each observation time), sparse spacetime grids
(regular, but incomplete grids), irregular spacetime data
(each observational unit is observed at its own time), and
has limited support for trajectory data. spacetime
classes have sp and xts objects as slots
for the spatial and temporal components, and can deal with all
spatial classes (points, lines, polygons, grids) of sp,
regular and irregular time series, and extend the powerful methods
(selection, aggregation, plotting coercion) from both packages.
 Dedicated classes: dedicated classes are offered for:
 Gridded/raster data: package raster deals with
sets of rasters (called bricks, or stacks), and a
set may reflect a temporal sequence
(use
setZ
on a brick or stack).
 Lattice data: package surveillance
provides a class
sts
, which holds a
SpatialPolygonsDataFrame
slot for the areas, and
numeric slots to define a regular time series (no time objects,
such as POSIXct
).
 Point patterns:
Package spatstat provides a class
ppx
that
deals spatial and temporal coordinate.
None of the point pattern classes mentioned support spatial or
explicit temporal reference systems.
 Trajectory data:
Package adehabitatLT offers a class
ltraj
for trajectories, and methods for analyzing them; the packages move and
trip both extend sp based classes for trajectories.
A blog post on tidy storm
trajectories points out how nested dataframes, along with
geometry list columns of the sf package, can be used to model sets
of trajectories, and visualise properties at the set level and
at the level of individual fixes.
Analyzing data
 Geostatistical data
 gstat provides kriging, methods of moments
variogram estimation and model fitting for a limited
range of spatiotemporal models.

IDE provides functionality for modelling
spatiotemporal data using the integrodifference
equation.

RandomFields provides kriging, conditional simulation,
and covariance functions and maximum likelihood function fitting
for a very wide range of spatiotemporal covariance models.

the spTimer package is able to fit,
spatially predict and temporally forecast large amounts
of spacetime data using Bayesian Gaussian Process
(GP) Models, Bayesian AutoRegressive (AR) Models,
and Bayesian Gaussian Predictive Processes (GPP)
based AR Models.

spBayes provides functions for fitting Bayesian dynamic
spacetime regression models for settings where space
is viewed as continuous but time is taken to be discrete.
 Stem provides estimation of the parameters
of a spatiotemporal model using the EM algorithm,
estimation of the parameter standard errors using a
spatiotemporal parametric bootstrap, spatial mapping.
 spate provides spatiotemporal modeling
of large data using a spectral SPDE approach.
 pastecs is a package for the regulation, decomposition
and analysis of spacetime series.
 STMedianPolish analyses spatiotemporal data, decomposing data in ndimensional arrays and using the median polish technique.
 RForge package spcopula
provides a framework to analyze via copulas spatial
and spatiotemporal data provided in the format of the
spacetime package. Additionally, support for calculating
different multivariate return periods is implemented.
 solaR is a package for computing solar radiation and photovoltaic
systems performance.
 nlme and lme4 contain functions
to fit linear mixed models, and have facilities to model
spatial and/or temporal effects.
 Point patterns

splancs provides methods for spatial and
spacetime point pattern analysis (khat, kernel3d,
visualizing).
 stam is an evolving package that target on
the various methods to conduct SpatioTemporal Analysis and
Modelling,including Exploratory SpatioTemporal Analysis
and Inferred SpatioTemporal Modelling, currently provides
mostly kernel density estimation.

ptproc (offCRAN) provides methods and classes for spatiotemporal
("multidimensional") point process.
 Lattice data
 surveillance provides temporal and spatiotemporal
modeling and monitoring of epidemic phenomena.

plm fits linear panel models.
 splm provides estimation and diagnostic
testing of econometric models for spatial panel data.
 sphet fit spatial models with heteroskedastic
innovations.
 nlme and lme4 contain functions
to fit linear mixed models, and have facilities to model
spatial and/or temporal effects.
 rsatscan provides an R interface to the free (but nonopen source) program SaTScan.
 CARBayesST implements a class of spatiotemporal
generalised linear mixed models for areal unit data, with inference
in a Bayesian setting using Markov chain Monte Carlo (McMC) simulation.
 gapfill provides tools to fill missing values in satellite data and to develop new gapfill algorithms. The methods are tailored to data (images) observed at equallyspaced points in time. The package is illustrated with MODIS NDVI data.
 Moving objects, trajectories
 There is a large (74+) and growing number of tracking, trajectory, movement and related packages on CRAN. A review paper by
Loo et al (2018)provides a guide to summarize many available packages and
their functionality.

adehabitatLT A collection of tools for the analysis of animal movements.

animalTrack 2D and 3D animal tracking data can be used to reconstruct tracks through time/space with correction based on known positions. 3D visualization of animal position and attitude.

anipaths Animation of observed trajectories using splinebased interpolation. Intended to be used exploratory data analysis, and perhaps for preparation of presentations.

argosfilter Functions to filters animal satellite tracking data
obtained from Argos. It is especially indicated for telemetry
studies of marine animals, where Argos locations are
predominantly of lowquality.

AtmRay Calculates acoustic traveltimes and ray paths in 1D,
linear atmospheres. Later versions will support arbitrary 1D
atmospheric models, such as radiosonde measurements and
standard reference atmospheres.

BayesianAnimalTracker Bayesian melding approach to combine the GPS observations and DeadReckoned path for an accurate animal's track, or equivalently, use the GPS observations to correct the DeadReckoned path. It can take the measurement errors in the GPS observations into account and provide uncertainty statement about the corrected path. The main calculation can be done by the BMAnimalTrack function.

BBMM The model provides an empirical estimate of a movement
path using discrete location data obtained at relatively short
time intervals.

bcpa The Behavioral Change Point Analysis (BCPA) is a method of
identifying hidden shifts in the underlying parameters of a time series,
developed specifically to be applied to animal movement data which is
irregularly sampled. The method is based on: E.
Gurarie, R. Andrews and K. Laidre A novel method for identifying
behavioural changes in animal movement data (2009) Ecology Letters 12:5
395408.

bsam Tools to fit Bayesian statespace models to animal tracking data. Models are provided for location
filtering, location filtering and behavioural state estimation, and their hierarchical versions.
The models are primarily intended for fitting to ARGOS satellite tracking data but options exist to fit
to other tracking data types. For Global Positioning System data, consider the 'moveHMM' package.
Simplified Markov Chain Monte Carlo convergence diagnostic plotting is provided but users are encouraged
to explore tools available in packages such as 'coda' and 'boa'.

caribou This is a package for estimating the population size of
migratory caribou herds based on large scale aggregations
monitored by radio telemetry. It implements the methodology
found in the article by Rivest et al. (1998) about caribou
abundance estimation. It also includes a function based on the
LincolnPetersen Index as applied to radio telemetry data by
White and Garrott (1990).

crawl Fit continuoustime correlated random walk models with time indexed
covariates to animal telemetry data. The model is fit using the Kalmanfilter on
a state space version of the continuoustime stochastic movement process.

ctmcmove Software to facilitates taking movement data in xyt format and pairing it with raster covariates within a continuous time Markov chain (CTMC) framework. As described in Hanks et al. (2015), this allows flexible modeling of movement in response to covariates (or covariate gradients) with model fitting possible within a Poisson GLM framework.

ctmm Functions for identifying, fitting, and applying continuousspace, continuoustime stochastic movement models to animal tracking data.

EMbC Unsupervised, multivariate, binary clustering for meaningful annotation of data, taking into account the uncertainty in the data. A specific constructor for trajectory analysis in movement ecology yields behavioural annotation of trajectories based on estimated local measures of velocity and turning angle, eventually with solar position covariate as a daytime indicator, ("ExpectationMaximization Binary Clustering for Behavioural Annotation").

eyelinker Eyelink eye trackers output a horrible mess, typically under
the form of a '.asc' file. The file in question is an assorted collection of
messages, events and raw data. This R package will attempt to make sense of it.

eyetracking Misc function for working with eyetracking data

fishmove Functions to predict fish movement parameters plotting leptokurtic fish dispersal kernels (see Radinger and Wolter, 2014: Patterns and predictors of fish dispersal in rivers. Fish and Fisheries. 15:456473.)

FLightR Spatiotemporal locations of an animal are computed
from annotated data with a hidden Markov model via particle
filter algorithm. The package is relatively robust to varying
degrees of shading.

foieGras Fits continuoustime random walk and correlated random walk statespace models to filter Argos satellite location data. Template Model Builder ('TMB') is used for fast estimation. The Argos data can be: (older) least squaresbased locations; (newer) Kalman filterbased locations with error ellipse information; or a mixture of both. Separate measurement models are used for these two data types. The models estimate two sets of location states corresponding to: 1) each observation, which are (usually) irregularly timed; and 2) userspecified time intervals (regular or irregular).

gazepath Eyetracking data must be transformed into fixations and saccades before it can be analyzed. This package provides a nonparametric speedbased approach to do this on a trial basis. The method is especially useful when there are large differences in data quality, as the thresholds are adjusted accordingly. The same preprocessing procedure can be applied to all participants, while accounting for individual differences in data quality.

GeoLight Provides basic functions for global
positioning based on light intensity measurements over time.
Positioning process includes the determination of sun events, a
discrimination of residency and movement periods, the
calibration of periodspecific data and, finally, the
calculation of positions.

marcher A set of tools for likelihoodbased estimation, model selection and testing of two and threerange shift and migration models for animal movement data as described in Gurarie et al. (2017). Provided movement data (X, Y and Time), including irregularly sampled data, functions estimate the time, duration and location of one or two range shifts, as well as the ranging area and autocorrelation structure of the movment. Tests assess, for example, whether the shift was "significant", and whether a twoshift migration was a true return migration.

mdftracks 'MTrackJ' is an 'ImageJ' plugin for motion tracking and analysis. This package reads
and writes 'MTrackJ Data Files' ('.mdf'). It supports
2D data and read/writes cluster, point, and channel information. If desired,
generates track identifiers that are unique over the clusters.
See the project page for more information and examples.

mkde Provides functions to compute and visualize movementbased kernel density estimates (MKDEs) for animal utilization distributions in 2 or 3 spatial dimensions.

momentuHMM Extended tools for analyzing telemetry data using generalized hidden Markov models. Features of momentuHMM (pronounced ``momentum'') include data preprocessing and visualization, fitting HMMs to location and auxiliary biotelemetry or environmental data, biased and correlated random walk movement models, multiple imputation for incorporating location measurement error and missing data, userspecified design matrices and constraints for covariate modelling of parameters, decoding of the state process, visualization of fitted models, model checking and selection, and simulation. See McClintock and Michelot (2018).

mousetrack Extract from twodimensional xy coordinates of an armreaching trajectory, several dependent measures such as area under the curve, latency to start the movement, xflips, etc.; which characterize the actiondynamics of the response. Mainly developed to analyze data coming from mousetracking experiments.

mousetrap Mousetracking, the analysis of mouse movements in computerized
experiments, is a method that is becoming increasingly popular in the
cognitive sciences. The mousetrap package offers functions for importing,
preprocessing, analyzing, aggregating, and visualizing mousetracking data.

move Contains functions to access movement data stored in 'movebank.org'
as well as tools to visualize and statistically analyze animal movement data,
among others functions to calculate dynamic Brownian Bridge Movement Models.
Move helps addressing movement ecology questions.

movecost Provides the facility to calculate nonisotropic accumulated cost surface and leastcost paths using a number of humanmovementrelated cost functions that can be selected by the user. It just requires a Digital Terrain Model, a start location and (optionally) destination locations.

moveHMM Provides tools for animal movement modelling using hidden Markov
models. These include processing of tracking data, fitting hidden Markov models
to movement data, visualization of data and fitted model, decoding of the state
process.

moveVis Tools to visualize movement data (e.g. from GPS tracking) and temporal changes of environmental data (e.g. from remote sensing) by creating video animations.

moveWindSpeed Estimating wind speed from trajectories of individually tracked birds using a maximum likelihood approach.

oce Supports the analysis of Oceanographic data, including 'ADCP'
measurements, measurements made with 'argo' floats, 'CTD' measurements,
sectional data, sealevel time series, coastline and topographic data, etc.
Provides specialized functions for calculating seawater properties such as
potential temperature in either the 'UNESCO' or 'TEOS10' equation of state.
Produces graphical displays that conform to the conventions of the
Oceanographic literature. This package is discussed extensively in
Dan Kelley's book Oceanographic Analysis with R, published
in 2018 by 'SpringerVerlag' with ISBN 9781493988426.

opentraj opentraj uses the Hybrid Single Particle Lagrangian Integrated Trajectory Model (HYSPLIT) for computing simple air parcel trajectories. The functions in this package allow users to run HYSPLIT for trajectory calculations, as well as get its results, directly from R without using any GUI interface.

rerddapXtracto Contains three functions that access
environmental data from any 'ERDDAP' data web service. The rxtracto() function extracts
data along a trajectory for a given "radius" around the point. The
rxtracto_3D() function extracts data in a box. The rxtractogon() function
extracts data in a polygon. All of those three function use the 'rerddap' package
to extract the data, and should work with any 'ERDDAP' server.
There are also two functions, plotBBox() and plotTrack() that use the 'plotdap'
package to simplify the creation of maps of the data.

riverdist Reads river network shape files and computes network distances.
Also included are a variety of computation and graphical tools designed
for fisheries telemetry research, such as minimum home range, kernel density
estimation, and clustering analysis using empirical kfunctions with
a bootstrap envelope. Tools are also provided for editing the river
networks, meaning there is no reliance on external software.

saccades Functions for detecting eye fixations in raw eyetracking
data. The detection is done using a velocitybased algorithm for
saccade detection proposed by Ralf Engbert and Reinhold Kliegl in
2003. The algorithm labels segments as saccades when the velocity of
the eye movement exceeds a certain threshold. Anything between two
saccades is considered a fixation. Thus the algorithm is not
appropriate for data containing episodes of smooth pursuit eye
movements.

SDLfilter Functions to filter GPS and/or Argos locations. The provided
filters remove temporal and spatial duplicates, fixes located at a given
height from estimated high tide line, and locations with high error as
proposed in Shimada et al. (2012) and
Shimada et al. (2016).

SimilarityMeasures Functions to run and assist four
different similarity measures. The similarity
measures included are: longest common
subsequence (LCSS), Frechet distance, edit distance
and dynamic time warping (DTW). Each of these
similarity measures can be calculated from two
ndimensional trajectories, both in matrix form.

SiMRiv Provides functions to generate and analyze spatiallyexplicit individualbased multistate movements in rivers,
heterogeneous and homogeneous spaces. This is done by incorporating landscape bias on local behaviour, based on
resistance rasters. Although originally conceived and designed to simulate trajectories of species constrained to
linear habitats/dendritic ecological networks (e.g. river networks), the simulation algorithm is built to be
highly flexible and can be applied to any (aquatic, semiaquatic or terrestrial) organism, independently on the
landscape in which it moves. Thus, the user will be able to use the package to simulate movements either in
homogeneous landscapes, heterogeneous landscapes (e.g. semiaquatic animal moving mainly along rivers but also using
the matrix), or even in highly contrasted landscapes (e.g. fish in a river network). The algorithm and its input
parameters are the same for all cases, so that results are comparable. Simulated trajectories can then be used as
mechanistic null models (Potts & Lewis 2014) to test a variety of 'Movement Ecology'
hypotheses (Nathan et al. 2008), including landscape effects (e.g. resources,
infrastructures) on animal movement and species site fidelity, or for predictive purposes (e.g. road mortality risk,
dispersal/connectivity). The package should be relevant to explore a broad spectrum of ecological phenomena, such as
those at the interface of animal behaviour, management, landscape and movement ecology, disease and invasive species
spread, and population dynamics.

smam Animal movement models including movingresting process
with embedded Brownian motion according to
Yan et al. (2014),
Pozdnyakov et al. (2017),
Brownian motion with measurement error according to
Pozdnyakov et al. (2014),
and movingrestinghandling process with embedded Brownian motion,
Pozdnyakov et al. (2018).

SpaTimeClus Mixture model is used to achieve the clustering goal. Each component is itself a mixture model of polynomial autoregressive regressions whose the logistic weights consider the spatial and temporal information.

stam stam is an evolving package that target on the various
methods to conduct SpatioTemporal Analysis and
Modelling,including Exploratory SpatioTemporal Analysis and
Inferred SpatioTemporal Modelling.

stampr Perform spatial temporal analysis of moving polygons; a
longstanding analysis problem in Geographic Information Systems. Facilitates
directional analysis, shape analysis, and some other simple functionality for
examining spatialtemporal patterns of moving polygons.

stplanr Tools for transport planning with an emphasis on spatial transport
data and nonmotorized modes. Enables common transport planning tasks including:
downloading and cleaning transport datasets; creating geographic "desire lines"
from origindestination (OD) data; route assignment, locally and via
interfaces to routing services such as http://cyclestreets.net
calculation of route segment attributes such as bearing and aggregate flow,
and 'travel watershed' analysis.
See Lovelace and Ellison (2018).

surveillance Statistical methods for the modeling and monitoring of time series
of counts, proportions and categorical data, as well as for the modeling
of continuoustime point processes of epidemic phenomena.
The monitoring methods focus on aberration detection in count data time
series from public health surveillance of communicable diseases, but
applications could just as well originate from environmetrics,
reliability engineering, econometrics, or social sciences. The package
implements many typical outbreak detection procedures such as the
(improved) Farrington algorithm, or the negative binomial GLRCUSUM
method of Höhle and Paul (2008).

trackdem Obtain population density and body size structure, using video material or image sequences as input. Functions assist in the creation of image sequences from videos, background detection and subtraction, particle identification and tracking. An artificial neural network can be trained for noise filtering. The goal is to supply accurate estimates of population size, structure and/or individual behavior, for use in evolutionary and ecological studies.

trackdf Data frame class for storing collective movement data (e.g. fish
schools, ungulate herds, baboon troops) collected from GPS trackers or
computer vision tracking software.

trackeR Provides infrastructure for handling running, cycling and swimming data from GPSenabled tracking devices within R. The package provides methods to extract, clean and organise workout and competition data into sessionbased and unitaware data objects of class 'trackeRdata' (S3 class). The information can then be visualised, summarised, and analysed through flexible and extensible methods. Frick and Kosmidis (2017) >, which is updated and maintained as one of the vignettes, provides detailed descriptions of the package and its methods, and realdata demonstrations of the package functionality.

trackeRapp Provides an integrated user interface and workflow for
the analysis of running, cycling and swimming data from GPSenabled
tracking devices.

TrackReconstruction Reconstructs animal tracks from magnetometer, accelerometer, depth and optional speed data. Designed primarily using data from Wildlife Computers Daily Diary tags deployed on northern fur seals.

trajectories Classes and methods for trajectory data, with support for nesting individual Track objects in track sets (Tracks) and track sets for different entities in collections of Tracks. Methods include selection, generalization, aggregation, intersection, simulation, and plotting.

trajr A toolbox to assist with statistical analysis of 2dimensional animal trajectories.
It provides simple access to algorithms for calculating and assessing a variety of
characteristics such as speed and acceleration, as well as multiple measures of
straightness or tortuosity. McLean & Skowron Volponi (2018).

trip Functions for accessing and manipulating spatial data for animal
tracking, with straightforward coercion from and to other formats. Filter
for speed and create time spent maps from animal track data. There are
coercion methods to convert between 'trip' and 'ltraj' from 'adehabitatLT',
and between 'trip' and 'psp' and 'ppp' from 'spatstat'. Trip objects
can be created from raw or grouped data frames, and from types in the 'sp',
'sf', 'amt', 'trackeR', 'mousetrap', and other packages.

tripEstimation Data handling and estimation functions for animal movement
estimation from archival or satellite tags. Helper functions are included
for making image summaries binned by time interval from Markov Chain Monte Carlo
simulations.

VTrack Designed to facilitate the assimilation, analysis and synthesis of animal location and movement data collected by the VEMCO suite of acoustic transmitters and receivers. As well as database and geographic information capabilities the principal feature of VTrack is the qualification and identification of ecologically relevant events from the acoustic detection and sensor data. This procedure condenses the acoustic detection database by orders of magnitude, greatly enhancing the synthesis of acoustic detection data.

wildlifeDI Dynamic interaction refers to spatialtemporal associations
in the movements of two (or more) animals. This package provides tools for
calculating a suite of indices used for quantifying dynamic interaction with
wildlife telemetry data. For more information on each of the methods employed
see the references within. The package (as of version 0.3) also has new tools for
automating contact analysis in large tracking datasets. The package draws
heavily on the classes and methods developed in the 'adehabitat' packages.
Visualization

rasterVis includes a variety of methods
that take advantage of the
z
slot of a
RasterStack
or
RasterBrick
object. Its webpage
includes several examples, from the hovmoller plot and
horizon graph, to the density and histogram plots.
 package plotKML provides methods to convert
spatiotemporal data into KML files, which can be displayed
by external viewers, in particular Google Earth. It has a
gallery too.

package googleVis provides an interface to show R data
(tables) in the
Google Chart Tools. spacetime has a
vignette
demonstrating its use for spatiotemporal data.

Package splancs provides
animation and 3D interactive plots (using rgl)
for displaying spatiotemporal point patterns.

mvtsplot provides multivariate time series plots,
with examples on spatiotemporal data, published by
Peng (2008, Journal of Statistical Software).
Data sets
 Table data for fitting linear panel models are found in plm.
 Package cshapes contains a data base with country boundaries,
varying over time.
 gstat contains the classic Irish wind data.
 spacetime contains rural PM10 air quality
measurements over Germany.

Some parts of the Cressie and Wikle (2011) book "Statistics for spatiotemporal
data" can be reproduced by
demo(CressieWikle)
in spacetime.
Retrieving data
Packages for retrieving data are:
 Package openair has tools to analyze, interpret and understand air pollution data, but also tools to download UK air quality data.
 ncdf4 and
RNetCDF allow reading and writing netcdf
files.

M3 contains functions to read in and manipulate air
quality model output from Models3formatted files. This format
is used by the Community Multiscale Air Quaility (CMAQ) model.

rmatio is a package for reading and writing Matlab MAT files from R.
 Task view: Spatial
 Task view: TimeSeries
 Task view: Econometrics
 Task view: Environmetrics
 Task view: DifferentialEquations
 RForget project: spcopula
 Pebesma (2012). spacetime: SpatioTemporal Data in R. Journal of Statistical Software, 51(7).
 Peng (2008). A Method for Visualizing Multivariate Time Series Data. Journal of Statistical Software, Code Snippets, 25(1).
 Gapminder world: A tool for visualization of economic and health indicators per country (including access to the underlying tables in timewide form).
 Wikle, C. K., ZammitMangion, A., and Cressie, N. (2019), SpatioTemporal Statistics with R, Boca Raton, FL: Chapman & Hall/CRC (free to download).