powered by
Apply to all layers of a SpatRaster a function that only takes a single layer SpatRaster and returns a SpatRaster (these are rare).
In most cases you can also use lapply or sapply for this.
lapply
sapply
# S4 method for SpatRaster sapp(x, fun, ..., filename="", overwrite=FALSE, wopt=list())
SpatRaster
a function that takes a SpatRaster argument and can be applied to each layer of x
x
additional arguments to be passed to fun
fun
character. Output filename
logical. If TRUE, filename is overwritten
TRUE
filename
list with named options for writing files as in writeRaster
writeRaster
lapp, app, tapp, lapply
# NOT RUN { s <- rast(system.file("ex/logo.tif", package="terra")) + 1 x <- sapp(s, terrain) # }
Run the code above in your browser using DataLab