geodist | R Documentation |
Calculate surface distance between geographic coordinates.
geodist(Nfrom, Efrom, Nto, Eto, units="km")
Nfrom |
latitude of origin. |
Efrom |
longitude of origin. |
Nto |
latitude of destination. |
Eto |
longitude of destination. |
units |
how distance is measured: |
Latitude and longitude are passed as decimal numbers, e.g. 66.5 for 66°30'N. Vectors of coordinates are supported.
Vector of distances.
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.
diff
, Trig
.
gmt-package
gives an overview of the package.
geodist(55.75,37.63, 39.9,116.4) # Moscow - Beijing geodist(90,0, -90,0, "nm") # from pole to pole
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.