haversine | R Documentation |
Compute the haversine distance between two (lon,lat) points. Uses Salvador's script in this page: https://stackoverflow.com/questions/27928/calculate-distance-between-two-latitude-longitude-points-haversine-formula
haversine(pt1, pt2, R = 6371)
pt1, pt2 |
numeric vectors of size at least 2 starting with (lon,lat) coordinates. If a third coordinate is present (e.g. elevation), it will be ignored. |
R |
numeric, Earth's radius in km. |
a numeric giving the distance between the two points in km
pt1=c(-32.917,151.75) #Newcastle, AU pt2=c(43.2964,5.37) #Marseille, FR haversine(pt1,pt2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.