Skip to contents

This functions allows to calculate precipitation statistics based on the CHIRPS rainfall estimates. Corresponding to the time-frame of the analysis of the portfolio, monthly precipitation statistics are calculated. These include the total rainfall amount, rainfall anomaly against the 1981-2010 climate normal, and the Standardized Precipitation Index (SPI) which is available for scales between 1 and 48 months. Th function needs the SPEI package to be installed. The required resources for this indicator are:

Format

A tibble with a column for years, months, absolute rainfall (in mm), rainfall anomaly (in mm) and one or more columns per selected time-scale for SPI (dimensionless).

Details

The following arguments can be set:

scales_spi

An integer vector indicating the scales for which to calculate the SPI.

spi_previous_year

An integer specifying how many previous years to include in order to fit the SPI. Defaults to 8 years.

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 = 2010,
      outdir = file.path(temp_loc, "res"),
      tmpdir = tempdir(),
      cores = 1,
      verbose = FALSE
    ) %>%
    get_resources("chirps") %>%
    calc_indicators("precipitation_chirps",
    engine = "exactextract",
    scales_spi = 3,
    spi_prev_years = 8) %>%
    tidyr::unnest(precipitation_chirps)))
}
#> Simple feature collection with 12 features and 9 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: 12 × 10
#>    WDPAID NAME           DESIG…¹ ISO3  assetid dates      absol…² anomaly  spi_3
#>     <dbl> <chr>          <chr>   <chr>   <int> <date>       <dbl>   <dbl>  <dbl>
#>  1 478140 Sierra de Nei… Nation… DOM         1 2010-01-01    17.9    7.49 -0.201
#>  2 478140 Sierra de Nei… Nation… DOM         1 2010-02-01    21.7    1.69  1.15 
#>  3 478140 Sierra de Nei… Nation… DOM         1 2010-03-01    33.3   -8.03  0.682
#>  4 478140 Sierra de Nei… Nation… DOM         1 2010-04-01   139.    37.3   0.507
#>  5 478140 Sierra de Nei… Nation… DOM         1 2010-05-01   178.   -16.1   0.172
#>  6 478140 Sierra de Nei… Nation… DOM         1 2010-06-01   206.    93.9   0.818
#>  7 478140 Sierra de Nei… Nation… DOM         1 2010-07-01   143.    67.9   0.989
#>  8 478140 Sierra de Nei… Nation… DOM         1 2010-08-01    96.7   -8.52  1.57 
#>  9 478140 Sierra de Nei… Nation… DOM         1 2010-09-01    96.5  -52.7   0.126
#> 10 478140 Sierra de Nei… Nation… DOM         1 2010-10-01    91.4  -52.4  -0.967
#> 11 478140 Sierra de Nei… Nation… DOM         1 2010-11-01   117.    31.3  -0.269
#> 12 478140 Sierra de Nei… Nation… DOM         1 2010-12-01    10.8   -2.07  0.229
#> # … with 1 more variable: geom <POLYGON [°]>, and abbreviated variable names
#> #   ¹​DESIG_ENG, ²​absolute