Compute zonal statistics. That is, cross-tabulate the values of a RasterLayer based on a "zones" RasterLayer.
zonal(raster, zones, stat='mean', na.rm=TRUE, progress)
- A RasterLayer object
- A RasterLayer object; with codes representing zones that are treated as integer values
- The function to be applied. Either as character: 'mean', 'min', 'max', 'sum'; or a function (see Details)
- Logical. If
TRUE, NA will be removed from the computations and the result will only be NA if all cells in a zone are NA
- Character. Valid values are "text", "tcltk", "windows" (on that platform only) and ""
stat is a
zonal will fail (gracefully) for very large RasterLayers
- A data frame with a value for each zone
r <- raster(ncols=10, nrows=10) r <- runif(ncell(r)) * 1:ncell(r) z <- r z <- rep(1:5, each=20) zonal(r, z, 'mean') zonal(r, z, 'min') zonal(r, z, 'sum') # using a function, rather than a character value zonal(r, z, sum)
Looks like there are no examples yet.