A simple distance calculator for two sets of geo coordinates. This function may be utilized to estimate the "straight line" distance between two sets of, e.g., Google Web Mercator/WGS 84 geocoordinates.

Share:

Description

A simple distance calculator for two sets of geo coordinates. This function may be utilized to estimate the "straight line" distance between two sets of, e.g., Google Web Mercator/WGS 84 geocoordinates.

Usage

1
dist_calc(long1, lat1, long2, lat2, units = "metric")

Arguments

long1

numeric; the longitude (degrees) of location 1.

lat1

numeric; the latitude (degrees) of location 1.

long2

numeric; the longitude (degrees) of location 2.

lat2

numeric; the latitude (degrees) of location 2.

units

character string; must be either "metric" (the default) or "imperial". Specifying "metric" will return the distance between location 1 and location in kilometers, whereas "imperial" returns the distance in miles.

References

http://menugget.blogspot.com/2011/05/r-functions-for-earth-geographic_29.html