xapp: Apply a function to the cells of a two SpatRasters

xappR Documentation

Apply a function to the cells of a two SpatRasters

Description

Apply a function to the values of each cell of two (multilayer) SpatRasters.

Usage

## S4 method for signature 'SpatRaster,SpatRaster'
xapp(x, y, fun, ..., filename="", overwrite=FALSE, wopt=list())

Arguments

x

SpatRaster

y

SpatRaster with the same geometry as x

fun

a function that operates on two vectors

...

additional arguments for fun. These are typically numerical constants. They should *never* be another SpatRaster

filename

character. Output filename

overwrite

logical. If TRUE, filename is overwritten

wopt

list with named options for writing files as in writeRaster

Value

SpatRaster

See Also

app, lapp, tapp, Math-methods, roll

Examples

r <- rast(ncols=10, nrows=10, nlyr=5)
set.seed(1)
r <- init(r, runif)
s <- init(r, runif)
x <- xapp(r, s, fun=cor)

terra documentation built on Oct. 14, 2024, 5:07 p.m.