Learn R Programming

terra (version 1.8-5)

diff: Lagged differences

Description

Compute the difference between consecutive layers in a SpatRaster.

Usage

# S4 method for SpatRaster
diff(x, lag=1, filename="", ...)

Value

SpatRaster

Arguments

x

SpatRaster

lag

positive integer indicating which lag to use

filename

character. Output filename

...

additional arguments for writing files as in writeRaster

Examples

Run this code
s <- rast(system.file("ex/logo.tif", package="terra"))   
d <- diff(s)

Run the code above in your browser using DataLab