This function allows to efficiently calculate the relative wetness in the shallow groundwater section with regard to the the 1948-2012 reference period. The values represent the wetness percentile a given area achieves at a given point in time in regard to the reference period. For each polygon, the desired statistic/s (mean, median or sd) is/are returned.
Arguments
- engine
The preferred processing functions from either one of "zonal", "extract" or "exactextract" as character.
- stats
Function to be applied to compute statistics for polygons either one or multiple inputs as character "mean", "median" or "sd".
Value
A function that returns a tibble with a column for each specified stats and a column with the respective date.
Examples
# \dontshow{
mapme.biodiversity:::.copy_resource_dir(file.path(tempdir(), "mapme-data"))
# }
# \dontrun{
library(sf)
library(mapme.biodiversity)
outdir <- file.path(tempdir(), "mapme-data")
dir.create(outdir, showWarnings = FALSE)
mapme_options(
outdir = outdir,
verbose = FALSE
)
aoi <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg",
package = "mapme.biodiversity"
) %>%
read_sf() %>%
get_resources(get_nasa_grace(years = 2022)) %>%
calc_indicators(
calc_drought_indicator(
engine = "extract",
stats = c("mean", "median")
)
) %>%
tidyr::unnest(drought_indicator)
#> Error in purrr::map(req_resources, function(resource_name) { resource <- avail_resources[[resource_name]] resource_type <- ifelse(inherits(resource, "sf"), "raster", "vector") reader <- switch(resource_type, raster = .read_raster, vector = .read_vector, stop(sprintf("Resource type '%s' currently not supported", resource_type))) reader(x, resource)}): ℹ In index: 1.
#> Caused by error in `reader()`:
#> ! Did not find equal number of tiles per timestep.
aoi
#> Error in eval(expr, envir, enclos): object 'aoi' not found
# }