Compute the risk for each of the epidemiological units.

risk_unit(r, eu, fun = mean)

Arguments

r

SpatRaster object

eu

sf or sfc object of type POLYGON

fun

A summary function. By default the mean.

Value

numeric vector of the same length as the number of epidemiological units.

Details

Summarises the level of risk using a function such as the mean or median value across the epidemiological unit.

Examples

  cmr <- mapMCDA_datasets()
  cmr$cmr_admin3$rv <- risk_unit(r = cmr$animal.density, eu = cmr$cmr_admin3)
  plot(cmr$cmr_admin3["rv"], pal = hcl.colors, nbreaks = 4, breaks = "quantile")