Calculate statistics from a gt_RasterLayer object using zones specified in a second gt_RasterLayer.

gt_zonal(x, z)

# S4 method for gt_RasterLayer,gt_RasterLayer
gt_zonal(x, z)

Arguments

x
gt_RasterLayer object.
z
gt_RasterLayer object with codes representing zones.

Value

matrix object with a value for each zone (unique values in) z. #' @details This function calculates the mean, median, mode, and standard deviation in each zone. It is similar to zonal.

Examples

## Not run: ------------------------------------ # g <- gt_raster(raster::raster(matrix(runif(9), ncol=3), # crs=sp::CRS('+init=epsg:4326'), # xmn=0, xmx=3, ymn=2, ymx=10)) # z <- gt_raster(raster::raster(matrix(sample(1:3, 9, replace=TRUE), ncol=3), # crs=sp::CRS('+init=epsg:4326'), # xmn=0, xmx=3, ymn=2, ymx=10)) # result <- gt_zonal(g, z) ## ---------------------------------------------