powered by
This function uses the Haversine forumula for calculating great circle distances between points. This formula is purpoted to work better than the spherical law of cosines for very short distances.
distance(targetLon, targetLat, longitude, latitude)
longitude (decimal degrees) of the point from which distances are calculated
latitude (decimal degrees) of the point from which distances are calculated
vector of longitudes for which a distance is calculated
vector of latitudes for which a distance is calculated
Vector of distances in km.
# NOT RUN { # Seattle to Portland airports SEA_lon <- -122.3088 SEA_lat <- 47.4502 PDX_lon <- -122.5951 PDX_lat <- 45.5898 distance(SEA_lon, SEA_lat, PDX_lon, PDX_lat) # }
Run the code above in your browser using DataLab