zonalDT | R Documentation |
A fast data.table
-based alternative to
raster::zonal()
.
zonalDT(x, z, fun = sum, na.rm = TRUE)
x |
A |
z |
A categorical |
fun |
A name or character string giving the function to be
applied to summarize the values by zone. It needs to return a
single (or at least a length-one vector). If |
na.rm |
Logical. If |
A data.table
with a summary value for each zone.
Joshua O'Brien
r <- raster(ncols = 10, nrows = 10) r[] <- runif(ncell(r)) * 1:ncell(r) z <- r z[] <- rep(1:5, each = 20) ## for big files, use a character value rather than a function zonalDT(r, z, "sum") ## for smaller files you can also provide a function zonalDT(r, z, mean) zonalDT(r, z, min) ## multiple layers zonalDT(stack(r, r*10), z, "sum")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.