Compute a raster file with the distances to the nearest vector feature, within the limits of a given mask.

distance_to_vector(x, mask)

Arguments

x

SpatVector object, or something convertible to.

mask

SpatRaster object

Value

SpatRaster object. Distance map in meters (even for unprojected maps in geographical coordinates).

Details

The resolution of the mask determines that of the outcome.

Examples

  cmr <- mapMCDA_datasets()
  dist_wb <- distance_to_vector(cmr$water_bodies, cmr$animal.density)
#> 
|---------|---------|---------|---------|
=========================================
                                          

  plot(dist_wb)