R: Lagged differences

diff {terra} | R Documentation

## Lagged differences

### Description

Compute the difference between consecutive layers in a SpatRaster.

### Usage

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

### Arguments

`x` | SpatRaster
`lag` | postive integer indicating which lag to use
`filename` | character. Output filename
`...` | additional arguments for writing files as in `writeRaster`

### Value

SpatRaster

### Examples

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

[Package terra version 1.3-22 Index]