Skip to contents

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. The required resources for this indicator are:

Format

A tibble with a column for each specified stats and a column with the respective date.

Details

The following arguments can be set:

stats_drought

Function to be applied to compute statistics for polygons either one or multiple inputs as character "mean", "median" or "sd".

engine

The preferred processing functions from either one of "zonal", "extract" or "exactextract" as character.

Examples

if (Sys.getenv("NOT_CRAN") == "true") {
  library(sf)
  library(mapme.biodiversity)

  temp_loc <- file.path(tempdir(), "mapme.biodiversity")
  if (!file.exists(temp_loc)) {
    dir.create(temp_loc)
    resource_dir <- system.file("res", package = "mapme.biodiversity")
    file.copy(resource_dir, temp_loc, recursive = TRUE)
  }

  (try(aoi <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg",
    package = "mapme.biodiversity"
  ) %>%
    read_sf() %>%
    init_portfolio(
      years = 2022,
      outdir = file.path(temp_loc, "res"),
      tmpdir = tempdir(),
      add_resources = FALSE,
      verbose = FALSE
    ) %>%
    get_resources("nasa_grace") %>%
    calc_indicators("drought_indicator",
      stats_drought = c("mean", "median"),
      engine = "extract"
    ) %>%
    tidyr::unnest(drought_indicator)))
}
#> Simple feature collection with 9 features and 8 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -71.80933 ymin: 18.57668 xmax: -71.33201 ymax: 18.69931
#> Geodetic CRS:  WGS 84
#> # A tibble: 9 × 9
#>   WDPAID NAME     DESIG_ENG ISO3  assetid wetness_mean wetness_median date      
#>    <dbl> <chr>    <chr>     <chr>   <int>        <dbl>          <dbl> <date>    
#> 1 478140 Sierra … National… DOM         1         58.1           58.1 2022-01-03
#> 2 478140 Sierra … National… DOM         1         56.0           56.0 2022-01-10
#> 3 478140 Sierra … National… DOM         1         54.3           54.3 2022-01-17
#> 4 478140 Sierra … National… DOM         1         53.7           53.7 2022-01-24
#> 5 478140 Sierra … National… DOM         1         44.2           44.2 2022-01-31
#> 6 478140 Sierra … National… DOM         1         54.8           54.8 2022-02-07
#> 7 478140 Sierra … National… DOM         1         77.5           77.5 2022-02-14
#> 8 478140 Sierra … National… DOM         1         77.7           77.7 2022-02-21
#> 9 478140 Sierra … National… DOM         1         77.2           77.2 2022-02-28
#> # ℹ 1 more variable: geom <POLYGON [°]>