| gedist | R Documentation | 
gedist computes the distance between the
coordinates in x and y. If y isn't
supplied, then the distances are computed between the
coordinates in x alone. Otherwise, the pairwise
distances between the points in x and y are
computed. If longlat = TRUE, then the great circle
distance is computed. eucdist is a simplified
version of gedist that computes Euclidean
distances alone while gcdist is a simplified
version of gedist that computes great circle
distance alone.
gedist(x, y = NULL, longlat = FALSE)
eucdist(x, y = NULL)
gcdist(x, y = NULL)
x | 
 A two-dimensional matrix of coordinates.  | 
y | 
 A two-dimensional matrix of coordinates.  | 
longlat | 
 A logical value indicating whether
Euclidean distance (  | 
The algorithm used when longlat = TRUE is a C++
port of the C code written by Roger Bivand for the
spDists function in the sp package, 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.
A matrix of distances
coords = matrix(runif(10), ncol = 2)
# euclidean distance
d = gedist(coords)
all.equal(d, as.matrix(dist(coords)),
          check.attributes = FALSE)
all.equal(gedist(coords), eucdist(coords))
# great circle distance
all.equal(gedist(coords, longlat = TRUE),
          gcdist(coords))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.