% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distance_time_polygons.R
\name{calc_min_distance_to_safety}
\alias{calc_min_distance_to_safety}
\title{Calculate minimum least-cost distance from origins to safety}
\usage{
calc_min_distance_to_safety(
  cs,
  origins,
  destinations,
  include_destinations = TRUE,
  progress = FALSE,
  progress_every = 1L,
  check_locations = FALSE
)
}
\arguments{
\item{cs}{A \code{leastcostpath} conductance surface.}

\item{origins}{Origin points.}

\item{destinations}{Escape/safety destination points.}

\item{include_destinations}{Logical. Add destination points with distance = 0.}

\item{progress}{Logical. Print simple progress messages.}

\item{progress_every}{Integer. Print progress every \code{n} origins when \code{progress = TRUE}.}

\item{check_locations}{Logical passed to \code{leastcostpath::create_lcp()}. The default
is \code{FALSE} for speed after inputs have already been projected and cropped.}
}
\value{
A point \code{SpatVector} with columns \code{distance} and \code{type}.
}
\description{
For each origin point, calculates least-cost paths to all candidate safety
points and stores the shortest finite path distance. Destination points are
appended to the output with distance equal to zero.
}
\examples{
dem <- terra::rast(nrows = 5, ncols = 5, xmin = 0, xmax = 5, ymin = 0, ymax = 5,
  vals = 1, crs = "EPSG:3857")
cs <- make_conductance_surface(dem)
origins <- terra::vect(data.frame(x = 0.5, y = 0.5), geom = c("x", "y"), crs = "EPSG:3857")
destinations <- terra::vect(data.frame(x = 4.5, y = 4.5), geom = c("x", "y"), crs = "EPSG:3857")
calc_min_distance_to_safety(cs, origins, destinations)
}
