haversine: Haversine distance

View source: R/Maps.R

haversineR Documentation

Haversine distance

Description

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

Usage

haversine(pt1, pt2, R = 6371)

Arguments

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.

Value

a numeric giving the distance between the two points in km

Examples

pt1=c(-32.917,151.75) #Newcastle, AU
pt2=c(43.2964,5.37) #Marseille, FR
haversine(pt1,pt2)

benRenard/BFunk documentation built on July 20, 2022, 7:07 a.m.