gcd: Great Circle Distance (GCD)

View source: R/great_circle_distance.R

gcdR Documentation

Great Circle Distance (GCD)

Description

Calculates the geodesic distance between two points specified by radian latitude/longitude using one of the Spherical Law of Cosines (slc), the Haversine formula (hf), or the Vincenty inverse formula for ellipsoids (vif).

Usage

gcd(p1, p2, type = "hf", na = 0)

Arguments

p1

Location of point 1 with (lat, long) coordinates.

p2

Location of point 2 with (lat, long) coordinates.

type

Specific algorithm to use, c('slc', 'hf', 'vif').

Value

Distance in kilometers (km).

References

http://www.r-bloggers.com/great-circle-distance-calculations-in-r/

Examples

# Point in (lat, long) format
p1 <- c(30.0, 120.0)
p2 <- c(30.5, 120.5)

gcd(p1, p2)
gcd(p1, p2, type="hf")
gcd(p1, p2, type="vif")

caesar0301/movr documentation built on June 18, 2022, 2:37 a.m.