google_distance.Rd
The Google Maps Distance Matrix API is a service that provides travel distance and time for a matrix of origins and destinations, based on the recommended route between start and end points.
google_distance(origins, destinations, mode = c("driving", "walking", "bicycling", "transit"), departure_time = NULL, arrival_time = NULL, avoid = NULL, units = c("metric", "imperial"), traffic_model = NULL, transit_mode = NULL, transit_routing_preference = NULL, language = NULL, key = get_api_key("distance"), simplify = TRUE, curl_proxy = NULL)
origins | Origin locations as either a one or two column data.frame, a list of unnamed elements, each element is either a numeric vector of lat/lon coordinates, an address string or a place_id, or a vector of a pair of lat / lon coordinates |
---|---|
destinations | destination locations as either a one or two column data.frame, a list of unnamed elements, each element is either a numeric vector of lat/lon coordinates, an address string or place_id, or a vector of a pair of lat / lon coordinates |
mode |
|
departure_time | The desired time of departure.
Use either a |
arrival_time | Specifies the desired time of arrival for transit requests.
Use either a |
avoid |
|
units |
|
traffic_model |
|
transit_mode |
|
transit_routing_preference |
|
language |
|
key |
|
simplify |
|
curl_proxy | a curl proxy object |
Either list or JSON string of the distance between origins and destinations
The amount of queries you can make to Google's APIs is dependent on both the service and the API you are using.
Each API has specific quotas and limits. Check Google's API documentation for details.
View your usage at the Google Cloud Console https://console.cloud.google.com/
Each API can only accept and return one request at a time. If you write a loop to make multiple API calls you should ensure you don't go over your quota / limits during the loop.
# NOT RUN { set_key("YOUR_GOOGLE_API_KEY") google_distance(origins = list(c("Melbourne Airport, Australia"), c("MCG, Melbourne, Australia"), c(-37.81659, 144.9841)), destinations = c("Portsea, Melbourne, Australia"), simplify = FALSE) google_distance(origins = c(-37.816, 144.9841), destinations = c("Melbourne Airport, Australia", "Flinders Street Station, Melbourne")) google_distance(origins = tram_stops[1:5, c("stop_lat", "stop_lon")], destinations = tram_stops[10:12, c("stop_lat", "stop_lon")],) # }