Skip to contents

The Frechet distance measures the similarity between two curves by considering the location and ordering of points along each curve. Uses the Euclidean metric.

Usage

ga_dist_frechet_pairwise(origin, dest)

Arguments

origin

a GeoArrow linestring array

dest

a GeoArrow linestring array; length 1 or the same length as origin

Value

a double vector of Frechet distance values

References

FrechetDistance

Examples

# a straight route against one that detours north
direct <- geoarrow::as_geoarrow_array(sf::st_sfc(
  sf::st_linestring(rbind(c(0, 0), c(2, 0), c(4, 0)))
))
detour <- geoarrow::as_geoarrow_array(sf::st_sfc(
  sf::st_linestring(rbind(c(0, 0), c(2, 1), c(4, 0)))
))

as.vector(ga_dist_frechet_pairwise(direct, detour))
#> [1] 1