Description Usage Arguments Examples
View source: R/dist_haversine.R
dist_haversine takes inputs of two sets of coordinates
in (radian values), one set fo reach location, and a boolean indicator of
whether or not to return the results as kilometers (km = TRUE) or
miles (km = FALSE). The output is the distance using the method
of the Haversine formula, a more robust distance between two points on the
surface of a sphere.
1  | dist_haversine(lat1, lon1, lat2, lon2, type = "deg", km = TRUE)
 | 
lat1 | 
 the latitude as radians of the first point  | 
lon1 | 
 the longitude as radians of the first point  | 
lat2 | 
 the latitude as radians of the second point  | 
lon2 | 
 the longitude as radians of the second point  | 
type | 
 defaults to "deg", can also be "rad"  | 
km | 
 boolean argument for whether to return results as km (TRUE) or miles (FALSE)  | 
1 2 3 4 5 6 7 8 9  | # Input list of degree values
# Longitude values range between 0 and +-180 degrees
deg.lon <- runif(2, -180, 180)
# Latitude values range between 0 and +-90 degrees
deg.lat <- runif(2, -90, 90)
# Obtain measures of distnace
hav.mi <- dist_haversine(lon1 = deg.lon[1], lat1 = deg.lat[1]
  , lon2 = deg.lon[2], lat2 = deg.lat[2], km = FALSE)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.