# Geodesic distance (great circle distance) between points

### Description

gdist() gives the geodesic distance between two points specified by latitude/longitude using Vincenty inverse formula for ellipsoids. The distance is given in nautical miles (the default), meters, kilometers, or miles. gdist.total() applies gdist() to any number of line segments.

### Usage

1 2 3 |

### Arguments

`lon.1` |
Longitude of the first point. |

`lat.1` |
Latitude of the first point. |

`lon.2` |
Longitude of the second point. |

`lat.2` |
Latitude of the second point. |

`units` |
Any one of "nm": nautical miles (the default), "m": meters, "km": kilometers, or "miles": miles, for units of the returned value. |

`a` |
Major semiaxes of the ellipsoid in meters. The default is for the Earth: 6378137.0 |

`b` |
Minor semiaxes of the ellipsoid in meters. The default is for the Earth: 6356752.3142 |

`verbose` |
Should extra information be output, the default is FALSE. |

`longlat` |
Two dimensional (n x 2) data in the form of a matrix or dataframe. The first column should be the longitude or x-axis column and the second the latitude or y-axis column. |

`segments` |
When there are more than two or more segments, should the distance for each segment be output. The default is TRUE. |

`digits` |
The number of rounding digits to use in the segment output. The default is 2. |

### Value

The total geodesic distance in the units specified.

### Author(s)

John R. Wallace: Imap.for.R@gmail.com (Limited support)

### References

Inspired by: http://www.movable-type.co.uk/scripts/LatLongVincenty.html

Vincenty, T. Direct and inverse solutions of geodesics on the ellipsoid with application of nested equations. Survey Review XXII, 176, April 1975. http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf

### See Also

`imap`

, `draw.lines`

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ```
## Not run:
imap() # Zoom into an area, right-click to stop.
gdist.total(draw.lines(rainbow(10), lwd=4)) # Left-click two or more times, right-click to stop.
# The total distance of the polygon's perimeter:
gdist.total(draw.polygon()) # Left-click three or more times, right-click to stop.
# The total distance of contiguous points (those not separated by NA's).
gdist.total(select.pts(imap()[[1]]$ll)) # Zoom in to an area, right-click, and then select points by creating a polygon with left-clicks.
## End(Not run)
``` |