Learn R Programming

TrackReconstruction (version 1.3)

CalcDistance: Calculate Distance Between Two Points

Description

Calculates the distance between two points on the globe given latitude and longitude in decimal degrees and returning distance in kilometers.

Usage

CalcDistance(initialLat, initialLong, finalLat, finalLong)

Arguments

initialLat

initial Latitude

initialLong

initial Longitude

finalLat

ending Latitude

finalLong

ending Longitude

Value

Distance in Kilometers

Details

Data must be provided in decimal degrees (e.g. 162.546). Longitude values west of the prime meridian are 0 to -180. Latitude values south of the equator are 0 to -90. This function is primarily used internally in the GPStable and GeoReference functions.

References

https://www.movable-type.co.uk/scripts/latlong.html

Examples

Run this code
# NOT RUN {
##Distance from New York to Los Angeles given Latitude and Longitude of New York and Los Angeles.
Howfar<-CalcDistance(40.7697,-73.9735,34.0522,-118.2428)
Howfar

# }

Run the code above in your browser using DataLab