geodist computes the distance between the coordinates in coords1 and coords2. If coords2 isn't supplied, then the distances are computed between the coordinates in coords1 alone. Otherwise, the pairwise distances between then points in coords1 and coords2 is computed. If longlat = TRUE, then the great circle distance is computed.
geodist(coords1, coords2, longlat =FALSE)
Arguments
coords1: A two-dimensional matrix of coordinates.
coords2: A two-dimensional matrix of coordinates.
longlat: A logical value indicating whether Euclidean distance (longlat = FALSE) or great circle distance (longlat = FALSE) should be computed. The default is longlat = FALSE.
Returns
A matrix of distances
Details
The algorithm used when longlat = TRUE is a C++ port of the C code written by Roger Bivand for spDists, which appears to be based on a special case of the Vincenty formula with a slight correction based on the WGS84 flattening constant. See https://en.wikipedia.org/wiki/Great-circle_distance.