Zonal toolset

Zonal Statistics

Zonal Statistics tool in ArcGIS pro is used for calculating the statistics on values of a raster within the zones of another dataset. In R we are able to produce similar results with the use of zonal function of the raster package.

r <- raster(ncols=10, nrows=10)
# generating random numbers that will used as values in our raster layer (r) - input values raster
values(r) <- runif(ncell(r)) * 1:ncell(r)

z <- r
# generating integer values for the raster layer z, which will be used as the zone raster
values(z) <- rep(1:5, each=20) 

# Zonal statistics - Summarize
zonal(r, z, "sum")

# Zonal statistics - Mean
zonal(r, z, "mean")

# Zonal statistics - Minimum
zonal(r, z, "min")


arc2r/book documentation built on March 5, 2021, 2:10 p.m.