R/roadPointDistance.R

Defines functions roadPointDistance

#' Compute distance between endpoints of road segments.
#'
#' @param a Numeric. Road point ID.
#' @param b Numeric. Road point ID.
#' @param meters Logical. Compute metric (meters) or nominal distance.
#' @noRd

roadPointDistance <- function(a = 85, b = 86, meters = FALSE) {
  sel <- cholera::roads$id %in% c(a, b)
  d <- stats::dist(cholera::roads[sel, c("x", "y")])
  ifelse(meters, cholera::unitMeter(d), d)
}

Try the cholera package in your browser

Any scripts or data that you put into this service are public.

cholera documentation built on March 7, 2023, 5:31 p.m.