# NOT RUN {
r <- raster(ncols=10, nrows=10)
values(r) <- runif(ncell(r)) * 1:ncell(r)
z <- r
values(z) <- rep(1:5, each=20)
# for large files, use a character value rather than a function
zonal(r, z, 'sum')
# for smaller files you can also provide a function
# }
# NOT RUN {
zonal(r, z, mean)
zonal(r, z, min)
# }
# NOT RUN {
# multiple layers
zonal(stack(r, r*10), z, 'sum')
# }
Run the code above in your browser using DataLab