Learn R Programming

caliver (version 2.0.0)

get_perc_risk_index: 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, poly, perc_val = 75, mod = "gt")

Arguments

b

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

poly

is the spatial polygon on which to aggregate the values

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

Run this code
# 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"
  
  # Read dummy polygon
  shape <- as(raster::extent(6, 18, 35, 47), "SpatialPolygons")
  # Set missing crs
  raster::crs(shape) <- "+proj=longlat +datum=WGS84 +no_defs"
  
  get_perc_risk_index(b = r_risico, poly = shape, perc_val = 75, mod = "gt")
  
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab