Compute map distances using Google
Compute map distances using Google's Distance Matrix API. Note: To use
Google's Distance Matrix API, you must first enable the API in the Google
Cloud Platform Console. See ?register_google
.
mapdist(from, to, mode = c("driving", "walking", "bicycling", "transit"), output = c("simple", "all"), urlonly = FALSE, override_limit = FALSE, ext = "com", inject = "", ...) distQueryCheck()
from |
name of origin addresses in a data frame (vector accepted) |
to |
name of destination addresses in a data frame (vector accepted) |
mode |
driving, bicycling, walking, or transit |
output |
amount of output |
urlonly |
return only the url? |
override_limit |
override the current query count (.google_distance_query_times) |
ext |
domain extension (e.g. "com", "co.nz") |
inject |
character string to add to the url |
... |
... |
if parameters from and to are specified as geographic coordinates, they are reverse geocoded with revgeocode. note that the google maps api limits to 2500 element queries a day.
a data frame (output="simple") or all of the geocoded information (output="all")
David Kahle david.kahle@gmail.com
## Not run: requires Google API key, see ?register_google ## basic usage ######################################## mapdist("waco, texas", "houston, texas") from <- c("houston, texas", "dallas") to <- "waco, texas" mapdist(from, to) mapdist(from, to, mode = "bicycling") mapdist(from, to, mode = "walking") from <- c( "1600 Amphitheatre Parkway, Mountain View, CA", "3111 World Drive Walt Disney World, Orlando, FL" ) to <- "1600 Pennsylvania Avenue, Washington DC" mapdist(from, to) from <- "st lukes hospital houston texas" to <- "houston zoo, houston texas" mapdist(from, to, mode = "transit") from <- c("houston", "houston", "dallas") to <- c("waco, texas", "san antonio", "houston") mapdist(from, to) ## geographic coordinates are accepted as well ######################################## (wh <- as.numeric(geocode("the white house, dc"))) (lm <- as.numeric(geocode("lincoln memorial washington dc"))) mapdist(wh, lm, mode = "walking") ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.