geodist {gmt}R Documentation

Distance Between Geographic Coordinates

Description

Calculate surface distance between geographic coordinates.

Usage

geodist(Nfrom, Efrom, Nto, Eto, units="km")

Arguments

Nfrom latitude of origin.
Efrom longitude of origin.
Nto latitude of destination.
Eto longitude of destination.
units how distance is measured: "km" for kilometres, "nm" for nautical miles.

Details

Latitude and longitude are passed as decimal numbers, e.g. 66.5 for 66°30'N. Vectors of coordinates are supported.

Value

Vector of distances.

Note

The surface distance between geographic coordinates is:

D = acos( sin(N1)*sin(N2) + cos(N1)*cos(N2)*cos(E1-E2) )

where distance and coordinates are expressed in radians. N1 and N2 is the latitude of origin and destination, and E1 and E2 is longitude.

The calculations assume a perfect sphere and elevation differences are ignored. The SI definition of a nautical mile is exactly 1.852 km.

Author(s)

Arni Magnusson arnima@u.washington.edu.

See Also

diff, Trig.

gmt-package gives an overview of the package.

Examples

geodist(55.75,37.63, 39.9,116.4)  # Moscow - Beijing
geodist(90,0, -90,0, "nm")        # from pole to pole

[Package gmt version 1.1-2 Index]