I am trying to use gmapsdistance on R to calculate multiple transit times from Google Maps.
I have a Google API key and can generate transit travel times for one origin and one destination with the following code:
gmapsdistance("51.7788868858975,-1.48196518842103"
, "51.76732413,-1.233620597" ,"transit",
"googleAPIKey")
However, i have a list of 1000+ origins and destinations in latitude and longitude that i want to find transit times and can only retrieve one at a time. I've tried to adapt the formula provided here to request multiple requests using GGMAP:
google_results <- rbind.fill(apply(subset(TravelExample, select=c("Origin", "Destination")), 1, function(x)
gmapsdistance(x2, x1, "transit", "googleAPIKey")))
I get the following error: Error in gmapsdistance(x2, x1, "transit", "googleAPIkey") :
Google maps is not able to find a route between origin and destination
I would use GGMAPS, but unfortunately you cannot request transit times from Google using the pakagage.
Any ideas how i can request multiple transit times using gmapsdistance?
Best Answer
I would suggest doing it within a loop. Here is a suggestion on how to do it
I have developed some preliminary code in Python in order to process multiple queries at the same time. You can find the preliminary verison in this link: https://github.com/rodazuero/gmapsdistancePY but you will have to adapt it yourself to your own need. I hope this helps.
Rodrigo