powered by
Apply a function to values of each cell of a SpatRaster. This is similar to apply -- think of each layer in a SpatRaster as a column (or row) in a matrix
apply
# S4 method for SpatRaster app(x, fun, ..., filename="", overwrite=FALSE, wopt=list())
SpatRaster object
function
additional arguments for fun
fun
character. Output filename. Optional
logical. If TRUE, filename is overwritten
TRUE
filename
list. Options for writing files as in writeRaster
writeRaster
SpatRaster
overlay, math
overlay
# 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