| global {terra} | R Documentation |
Compute global statistics, that is summarized values of an entire SpatRaster.
If x is very large global will fail, except when fun is one of "mean", "min", "max", "sum", "prod", "range" (min and max), "rms" (root mean square), "sd" (sample standard deviation), "sdpop" (population standard deviation), "isNA" (number of cells that are NA), "notNA" (number of cells that are not NA).
You can compute a weighted mean or sum by providing a SpatRaster with weights.
## S4 method for signature 'SpatRaster' global(x, fun="mean", weights=NULL, ...)
x |
SpatRaster |
fun |
function to be applied to summarize the values by zone. Either as one of these character values: "max", "min", "mean", "sum", "range", "rms" (root mean square), "sd", "std" (population sd, using |
... |
additional arguments passed on to |
weights |
NULL or SpatRaster |
A data.frame with a row for each layer
zonal for "zonal" statistics, and app or Summary-methods for "local" statistics, and extract for summarizing values for polygons. Also see focal for "focal" or "moving window" operations.
r <- rast(ncols=10, nrows=10) values(r) <- 1:ncell(r) global(r, "sum") global(r, "mean", na.rm=TRUE)