terra (version 1.0-10)

arith: apply a local function

Description

Apply a function that (arithmetically) operates to individual cells and layers of a SpatRaster, to return the same number of layers as in the input SpatRaster. That, is unlike with app, without summarizing over layers.

Usage

# S4 method for SpatRaster
arith(x, fun, ..., filename="", overwrite=FALSE, wopt=list())

Arguments

x

SpatRaster

fun

function

...

additional arguments for fun

filename

character. Output filename. Optional

overwrite

logical. If TRUE, filename is overwritten

wopt

list. Options for writing files as in writeRaster

Value

SpatRaster

See Also

arith

Examples

Run this code
# NOT RUN {
r <- rast(ncols=10, nrows=10)
values(r) <- 1:ncell(r)

x <- arith(r, sqrt)

# equivalent to 
y <- sqrt(x)
# }

Run the code above in your browser using DataLab