distance: Vincenty Direct Calculation of Distance and Direction

Description Usage Arguments Value Author(s) Source References See Also Examples

Description

distance estimates the distance given a starting & ending latitude and longitude.

For general information on Vincenty's formula, see e.g., http://en.wikipedia.org/wiki/Vincenty's_formulae. It states:
Vincenty's formulae are two related iterative methods used in geodesy to calculate the distance between two points on the surface of an spheroid, developed by Thaddeus Vincenty in 1975. They are based on the assumption that the figure of the Earth is an oblate spheroid, and hence are more accurate than methods such as great-circle distance which assume a spherical Earth.

Note: this method assumes a locations are lat & lon given in WGS 84.

Direction, if requested, is the the initial bearing (sometimes referred to as forward azimuth) for which one would follow as a straight line along a great-circle arc from start to finish.

Note: this will fail if there are NA's in the data.

Usage

1
distance(lat1, lon1 = NULL, lat2 = NULL, lon2 = NULL, bearing = FALSE)

Arguments

lat1

a single value or vector of values representing latitude in decimal degrees from -90 to 90 degrees. Alternatively, a data.frame or matrix can be used here with each column representing lat1, lon1, lat2, lon2 (in that order).

lon1

a single value or vector of values representing longitude in decimal degrees from -180 to 180 degrees. If NULL, lat1 is assumed to be a matrix or data.frame.

lat2

a single value or vector of values representing latitude in decimal degrees from -90 to 90 degrees. If NULL, lat1 is assumed to be a matrix or data.frame.

lon2

a single value or vector of values representing longitude in decimal degrees from -180 to 180 degrees. If NULL, lat1 is assumed to be a matrix or data.frame.

bearing

boolean value as to calculate the direction as well as the distance.

Value

Returns a data.frame with:

lon1

the original longitude

lat1

the original latitude

lon2

the destination longitude

lat2

the destination latitude

distance

the distance used

bearing

if requested, the bearing between the two points

Author(s)

Jeremy VanDerWal jjvanderwal@gmail.com

Source

The source code for the distance algorithm here was modified from http://www.movable-type.co.uk/scripts/latlong-vincenty.html.

Distances were validated against Geoscience Australia calculations (http://www.ga.gov.au/geodesy/datums/vincenty_inverse.jsp).

Bearings were from multiple sources including http://williams.best.vwh.net/avform.htm#Crs.

References

Vincenty, T. 1975. Direct and Inverse Solutions of Geodesics on the Ellipsoid with application of Nested Equations. Survey Review, vol XXII no 176. http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf

See Also

destination

Examples

1
2
#get the distance of 1 degree longitude at each 5 degrees latitude from -90 to 90
distance(lat1=seq(-90,90,5),lon1=rep(0,37),lat2=seq(-90,90,5),lon2=rep(1,37),bearing=TRUE)

jjvanderwal/SDMTools documentation built on May 19, 2019, 11:40 a.m.