
Calculate geographic distance via Haversine formula (helper)
Source:R/helper_indices.R
geodist_helper.Rd
Computes the geographic (Haversine) distance in meters between two coordinate
pairs, or returns 0 for single-site (order=1) calculations when vec_to
is NULL
.
Usage
geodist_helper(
vec_from,
vec_to = NULL,
coord_cols = c("centroid_lon", "centroid_lat")
)
Arguments
- vec_from
Numeric vector of length 2, or a named vector containing coordinates. If named, should include names given by
coord_cols
.- vec_to
Optional numeric vector of length 2 (destination coordinates); if
NULL
(default), the function returns 0.- coord_cols
Character vector of length 2 giving the names of the longitude and latitude elements in
vec_from
/vec_to
when those are named vectors. Defaults toc("x", "y")
.