Learn R Programming

terra (version 0.5-2)

app: Apply a function to the cells of a SpatRaster

Description

Apply a function to values of a SpatRaster. Similar to apply

Usage

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

Arguments

x

SpatRaster object

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

overlay, math

Examples

Run this code
# NOT RUN {
r <- rast(ncols=10, nrows=10)
values(r) <- 1:ncell(r)
x <- c(r, r, r)
s <- app(x, fun=sum)
# }

Run the code above in your browser using DataLab