Compute zonal statistics, that is summarized values of a SpatRaster for each "zone" defined by another SpatRaster.
If fun is a true function, zonal may fail for very large SpatRaster objects, except for the functions ("mean", "min", "max", or "sum").
Usage
# S4 method for SpatRaster,SpatRaster
zonal(x, z, fun=mean, ...)
Arguments
x
SpatRaster
z
SpatRaster with values representing zones
fun
function to be applied to summarize the values by zone. Either as character: "mean", "min", "max", "sum", or, for relatively small SpatRasters, a proper function
...
additional arguments passed to fun
Value
A data.frame with a value for each zone (unique value in zones)
See Also
See global for "global" statistics (i.e., all of x is considered a single zone), app for local statistics, and extract for summarizing values for polygons