get_perc_risk_index: get_perc_risk_index

Description Usage Arguments Value Examples

View source: R/get_perc_risk_index.R

Description

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## 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")
  

## End(Not run)

caliver documentation built on Feb. 19, 2021, 5:07 p.m.