问题
Apologies for repeating a question, but I've haven't been able to fix the problem with the answers I found. I'm working with transport-workshop.Rmd from this repo: https://github.com/nickbearman/transport-workshop. The first 3 queries I make with qmap work no problem qmap('Leeds')
, qmap('LS2 9JT')
and qmap('LS2 9JT', zoom = 17)
. But then I go on with the workshop and try qmap('LS2 9JT', zoom = 17, maptype = 'satellite')
, which returns me this error:
geocode failed with status OVER_QUERY_LIMIT, location = "LS2 9JT"Error in data.frame(ll.lat = ll[1], ll.lon = ll[2], ur.lat = ur[1], ur.lon = ur[2]) :
arguments imply differing number of rows: 0, 1
When checking:
> geocodeQueryCheck()
2495 geocoding queries remaining.
Found that specifying a Google Maps API key may sort it out:
devtools::install_github("dkahle/ggmap")
register_google(key = "my_api_key")
from https://developers.google.com/maps/documentation/geocoding/get-api-key , but I keep getting the same error. Not sure what else to check or try.
Working with R version 3.4.3 (2017-11-30), Windows 10.
回答1:
There can be two reasons for this :
1) You may have exceeded a 24-hour limit
if you are using free version of google API. You can either go for premium service or check the limit policy for service which you are using here
2) You are crossing limit of requests per second
by hitting geocode multiple times in one second . So you can change your code and add the wait time before next request to avoid this error.
回答2:
I also had the same problem again and again. If you are running multiple queries in a loop you can insert a pause like Sys.sleep(5)
.
But from my experience, for all the Google related queries, I found the package googleway
much better than ggmap
. Maybe you try this? Note: here you will need a key, which you will easily get after registering at Google.
回答3:
I have had this experience too. Sometimes even the helpful fixes proposed by Rohan Kadu and DatamineR don't fix the problem (though I haven't tried googleway
).
You might also try changing the ggmap source to "dsk" for Data Science Toolkit like this:
result <- geocode(df$Address, output = "latlona", source = "dsk")
This has worked for me. (Though dsk
has a few limitations. Have a look at the ggmap
documentation.)
Good luck.
来源:https://stackoverflow.com/questions/49108756/geocode-failed-with-status-over-query-limit-r-studio