Compute a raster map from the input layer and rescale with a linear relationship.

risk_layer(x, boundaries, scale_target = c(0, 100))

Arguments

x

a sf, sfc, SpatRaster or igraph object

boundaries

a sf or sfc object, used to determine the boundaries of the computed risk layer.

scale_target

numeric vector of length 2. New scale.

Value

A SpatRaster object in the new scale.

Details

For sf objects (geometries such as point, lines or polygons), compute the distance_map(), which gives a SpatRaster. For igraph objects (from network data), compute a SpatRaster with the relative importance of the nearest node. For a SpatRaster mask, extend or crop to the boundaries as needed.

Finally, scale the SpatRaster outcome of any of the three input types. If you need an inverse relationship, just reverse the target scale.

Examples

  ad <- mapMCDA_datasets()$animal.density
  bd <- mapMCDA_datasets()$cmr_admin3
  plot(ad)

  plot(risk_layer(ad, bd, scale_target = c(-1, 1)))

  plot(risk_layer(ad, bd, scale_target = c(1, -1)))