gcDist | R Documentation |
given the coordinates in the longitude and latitude it computes the distance between these points. The default distance computed is in kilometers.
gcDist(x1, y1, x2, y2, R = 6371)
x1 |
longitude of the first location set |
y1 |
latitude of the second location set |
x2 |
longitude of the first location set |
y2 |
latitude of the second location set |
R |
the radius. Default is 6371 giving the the resulting distance in kilometers for the chordal distance around the Earth. |
## Consider some locations
locs <- rbind(
Paris=c(2.3295489, 48.8588377),
Berlin=c(13.4072169, 52.5067614),
Curitiba=c(-49.2582225, -25.4420471),
Tokyo=c(139.6708224, 35.6681625))
locs
apply(locs, 1, function(xy)
gcDist(xy[1], xy[2], locs[,1], locs[,2]))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.