zonal_operation: Compute zonal statistics from provided raster files

View source: R/zonal_operation.R

zonal_operationR Documentation

Compute zonal statistics from provided raster files

Description

Compute zonal statistics from provided raster files

Usage

zonal_operation(aoi = NULL, idcol = NULL, rast = NULL, opn = "mean")

Arguments

aoi

An sf object with polygons representing areas of interest

idcol

A character vector identifying a column name which uniquely identifies the polygons in the aoi object.

rast

A raster object as spatRaster on which to perform zonal operation

opn

A type of zonal operation (sum/mean/min/max) - mean being default value

Value

A dataframe with zonal statistics

Examples



# load raster
rast <- terra::rast(system.file("extdata", "test_worldpop2020.tif", package = "openRspat"))
# load polygon
aoi <- sf::st_read(system.file("extdata", "test_wdpa.gpkg", package = "openRspat"))
# provide unique id column
idcol <- "WDPAID"
# zonal operation type
opn <- "min"
# call function
zonal_operation(aoi, idcol, rast, opn)



Ohm-Np/openRspat documentation built on June 23, 2022, 3:03 p.m.