Skip to contents

Per pixel distance to nearest access vector. Intended to be used as a `cost` constraint within the sample_clhs function

Usage

calculate_distance(
  raster,
  access,
  plot = FALSE,
  filename = NULL,
  overwrite = FALSE
)

Arguments

raster

spatRaster. Raster to be used to calculate pixel level distance to access layer.

access

sf 'LINESTRING' or 'MULTILINESTRING'. Access network.

plot

Logical. Plots output strata raster with samples.

filename

Character. Path to write output samples.

overwrite

Logical. Choice to overwrite existing filename if it exists.

Value

Input raster with dist2access layer appended.

Author

Tristan R.H. Goodbody

Examples

if (FALSE) {
#--- Load raster and access files ---#
r <- system.file("extdata", "mraster_small.tif", package = "sgsR")
mr <- terra::rast(r)

a <- system.file("extdata", "access.shp", package = "sgsR")
ac <- sf::st_read(a)

calculate_distance(
  raster = mr,
  access = ac,
)
}