Returns a distance map (in meters) to spatial features.

distance_map(x, boundaries, res = resolution(boundaries, max_ncells = 100))

Arguments

x

sf or sfc object with relevant spatial features.

boundaries

sf or sfc POLYGON object with administrative borders, or SpatRaster object from where to pick the resolution.

res

numeric. Resolution for the outcome distance map. The default divides the smallest dimension into 100 cells.

Value

A raster map with distances in meters to the closest spatial feature.

Details

Distances are computed up to the given boundaries and at given resolution.

Examples

  cmr <- mapMCDA_datasets()
  plot(distance_map(x = cmr$water_bodies, boundaries = cmr$cmr_admin3))
#> 
|---------|---------|---------|---------|
=========================================