ssmooth

R-CMD-check format-check

Run time series smoothing on terra::SpatRaster objects. Applies a simple smoothing algorithm to each pixels’ time series. Currently supports simple moving average, weighted moving average, and exponential smoothing.

Installation

Install from CRAN via:

install.packages("ssmooth")

Alternatively, install the development version from this GitHub repo via:

# install.packages("pak")
pak::pkg_install("Biodiversity-Futures-Lab/ssmooth")

Usage

The main function of interest is SmoothRasterTS, which applies a smoother over the raster time-series:

# library(ssmooth)
r <- terra::rast(nrow = 2, ncol = 2, nlyrs = 10)
terra::values(r) <- rep(1:4, each = 10)
SmoothRasterTS(r, "mean")

We assume that the layers are temporally ordered (oldest -> newest): if time information is detected in the layers (terra::time()), then smoothing will be applied in temporal order. If no time information is found then smoothing will be applied across layers in the order given.

As well, we also provide a lower-level function SmoothTS that applies smoothing to a single numeric vector, which is what SmoothRasterTS uses under the hood:

# library(ssmooth)
x <- runif(10)
SmoothTS(x, "mean", n = 3)