Calculate the distance between each pair of geometries in origin and
dest. These functions differ in the metric space used for the calculation.
Usage
ga_dist_euclidean_pairwise(origin, dest)
ga_dist_haversine_pairwise(origin, dest)
ga_dist_geodesic_pairwise(origin, dest)
ga_dist_rhumb_pairwise(origin, dest)Details
ga_dist_euclidean_pairwise() measures between geometries of any type, so
the distance from a point to the nearest edge of a polygon is one call. The
spherical and ellipsoidal metrics take points only, because geo defines
them between points alone.
Examples
# Raleigh to Charlotte, and Raleigh to Wilmington
origin <- ga_xy(c(-78.6382, -78.6382), c(35.7796, 35.7796))
dest <- ga_xy(c(-80.8431, -77.9447), c(35.2271, 34.2257))
# degrees, then meters
as.vector(ga_dist_euclidean_pairwise(origin, dest))
#> [1] 2.273068 1.701631
as.vector(ga_dist_geodesic_pairwise(origin, dest))
#> [1] 209216.6 183645.3