Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
352 views
in Technique[技术] by (71.8m points)

r - Getting OVER QUERY LIMIT after one request with geocode

I'm using the ggmap's geocode to find the latitude and longitude of different cities. It worked completely fine yesterday but I get an OVER QUERY LIMIT after only one request today.

In fact if I just load the library and run geocode it throws the OVER QUERY LIMIT error:

> library(ggmap)
> geocode("Paris")
Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Paris&sensor=false
  lon lat
1  NA  NA
Warning message:
geocode failed with status OVER_QUERY_LIMIT, location = "Paris" 

I checked different topics on stackoverflow but nobody seems to have the same problem. I tried to see if I was over the 2500 limit (very unlikely but I'm new to coding so maybe I did something wrong...) and geocodeQueryCheck() reads 2498 but then again it resets every time I run library(ggmap).

It worked once fifteen minutes ago when I rebooted Rstudio but now it doesn't work anymore, I'm completely lost!

Does anyone have any idea what might be the problem?

PS: I'm new to stackoverflow so if you have any remark on anything please tell me!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had a similar problem using ggmap::geocode() for a batch of locations where roughly 20% of locations gave the OVER QUERY LIMIT error even though geocodeQueryCheck() would show more than enough geocoding queries remaining, and the errors were sporadically spread throughout the locations, not just the last 20%. If I reran the subset of locations that failed the first time, again most would work, so I had to iterate through smaller subsets until they all had geocodes.

ggmap v2.7 allows the user to specify a Google Maps API key through the register_google() function. v2.7 is not on CRAN yet, so you have to use devtools::install_github("dkahle/ggmap") to install it. After updating to that version and setting my API Key register_google(key = "my_api_key"), the same batch worked in one run as expected.

The Google Maps API Key is easy to get: https://developers.google.com/maps/documentation/geocoding/get-api-key


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...