get_perc_risk_index: get_perc_risk_index

View source: R/get_perc_risk_index.R

get_perc_risk_indexR Documentation

get_perc_risk_index

Description

Generates the mean of the values over a certain percentile threshold for the portion of the Raster* that intersects a polygon

Usage

get_perc_risk_index(b, p, perc_val = 75, mod = "gt")

Arguments

b

RasterLayer/Brick/Stack containing the historical observations or a proxy (typically a reanalysis).

p

SpatialPolygons* object

perc_val

is the percentile value used as a threshold

mod

defines if the values considered for the mean are above (gt) or below (lt) the threshold

Value

The function returns a numeric value (for each layer in b), corresponding to the mean of the values of b above/below a given percentile of the historical observations.

Examples

## Not run: 
  # Read RISICO test data
  r_risico <- readRDS(system.file("extdata", "RISICO_raster.rds",
                                  package = "caliver"))
  # Set missing crs
  raster::crs(r_risico) <- "+proj=longlat +datum=WGS84 +no_defs"
  
  # Define dummy polygon, as sf simple feature
  shape <- sf::st_bbox(c(xmin = 7, xmax = 18, ymax = 40, ymin = 18),
                       crs = sf::st_crs(4326))
  
  get_perc_risk_index(b = r_risico, p = shape, perc_val = 75, mod = "gt")
  

## End(Not run)


ecmwf/caliver documentation built on March 25, 2022, 6:59 a.m.