sapp | R Documentation |
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.
Or apply the same method to each sub-dataset (SpatRaster) in a SpatRasterDataset
## S4 method for signature 'SpatRaster'
sapp(x, fun, ..., filename="", overwrite=FALSE, wopt=list())
## S4 method for signature 'SpatRasterDataset'
sapp(x, fun, ..., filename="", overwrite=FALSE, wopt=list())
x |
SpatRaster or SpatRasterDataset |
fun |
if |
... |
additional arguments to be passed to |
filename |
character. Output filename |
overwrite |
logical. If |
wopt |
list with named options for writing files as in |
SpatRaster
lapp, app, tapp, lapply
s <- rast(system.file("ex/logo.tif", package="terra")) + 1
#SpatRasterDataset
sd <- sds(s*2, s/2)
y <- sapp(sd, mean)
z <- sapp(sd, \(i) 2 * mean(i))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.