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^{\circ}30'N. Vectors of coordinates are supported.

Value

Vector of distances.

Note

The surface distance between geographic coordinates is:

D \:=\: \cos^{-1}\!\!\big[\:\!\!\sin\theta_1\sin\theta_2 \,+\, \cos\theta_1\cos\theta_2\cos(\phi_1\;\!\!\!-\!\phi_2)\big]

where distance and coordinates are expressed in radians. \theta_1 and \theta_2 is the latitude of origin and destination, and \phi_1 and \phi_2 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.

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 2.0.3 Index]