R: Vincenty Direct Calculation of Distance and Direction
distance
R Documentation
Vincenty Direct Calculation of Distance and Direction
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.
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.
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
#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)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(SDMTools)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SDMTools/distance.Rd_%03d_medium.png", width=480, height=480)
> ### Name: distance
> ### Title: Vincenty Direct Calculation of Distance and Direction
> ### Aliases: distance
>
> ### ** Examples
>
> #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)
lat1 lon1 lat2 lon2 distance bearing
1 -90 0 -90 1 0.00 90.50000
2 -85 0 -85 1 9734.15 90.49810
3 -80 0 -80 1 19391.28 90.49240
4 -75 0 -75 1 28895.14 90.48296
5 -70 0 -70 1 38171.07 90.46985
6 -65 0 -65 1 47146.67 90.45316
7 -60 0 -60 1 55752.52 90.43302
8 -55 0 -55 1 63922.76 90.40958
9 -50 0 -50 1 71595.61 90.38303
10 -45 0 -45 1 78713.83 90.35356
11 -40 0 -40 1 85225.05 90.32140
12 -35 0 -35 1 91082.08 90.28679
13 -30 0 -30 1 96243.05 90.25000
14 -25 0 -25 1 100671.60 90.21131
15 -20 0 -20 1 104336.93 90.17101
16 -15 0 -15 1 107213.84 90.12941
17 -10 0 -10 1 109282.75 90.08683
18 -5 0 -5 1 110529.68 90.04358
19 0 0 0 1 110946.26 90.00000
20 5 0 5 1 110529.68 89.95642
21 10 0 10 1 109282.75 89.91317
22 15 0 15 1 107213.84 89.87059
23 20 0 20 1 104336.93 89.82899
24 25 0 25 1 100671.60 89.78869
25 30 0 30 1 96243.05 89.75000
26 35 0 35 1 91082.08 89.71321
27 40 0 40 1 85225.05 89.67860
28 45 0 45 1 78713.83 89.64644
29 50 0 50 1 71595.61 89.61697
30 55 0 55 1 63922.76 89.59042
31 60 0 60 1 55752.52 89.56698
32 65 0 65 1 47146.67 89.54684
33 70 0 70 1 38171.07 89.53015
34 75 0 75 1 28895.14 89.51704
35 80 0 80 1 19391.28 89.50760
36 85 0 85 1 9734.15 89.50190
37 90 0 90 1 0.00 89.50000
>
>
>
>
>
> dev.off()
null device
1
>