View source: R/zonal_operation.R
zonal_operation | R Documentation |
Compute zonal statistics from provided raster files
zonal_operation(aoi = NULL, idcol = NULL, rast = NULL, opn = "mean")
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 |
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 |
A dataframe with zonal statistics
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.