Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 640
Edouard Cuny Avatar asked Mar 23 '16 10:03

Edouard Cuny


People also ask

What happens when you exceed the Google geocoding API rate limit 1 point?

According to Google's API Usage and Billing page, there is a limit of 50 requests per second. If you exceed this amount, subsequent requests to the API will fail with the OVER_DAILY_LIMIT or OVER_QUERY_LIMIT status code and the geocoded data will not be returned.

What is the maximum limit for the number of geocode requests?

While there is no maximum number of requests per day, the following usage limit is still in place for the Geocoding API: 50 requests per second, calculated as the sum of client-side and server-side queries.

What does over query limit mean?

If status code is still OVER_QUERY_LIMIT, your application is sending too many requests per day. Otherwise, your application is sending too many requests per second."

How accurate is Google geocoding?

Results. Respectively 81.4% and 84.4% of addresses were geocoded to the exact address (65.1% and 61.4%) or to the street segment (16.3% and 23.0%) with methods A and B. In the reference layer, geocoding accuracy was higher in urban areas compared to rural areas (74.4% vs.


3 Answers

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

like image 138
sbha Avatar answered Oct 19 '22 23:10

sbha


Tried to register for api_key, looks like a paid service.

source = “dsk” seems to be the only workaround:

geocode("Paris", source = "dsk")

See if it works for you.

like image 10
Ghose Bishwajit Avatar answered Oct 19 '22 23:10

Ghose Bishwajit


If you want to be sure of your quota you can obtain a Google Maps API key, then use it in my googleway package

library(googleway)

key <- "your_api_key"

google_geocode(address = "Paris", key = key)

# $results
# address_components
# 1   Paris, Paris, Île-de-France, France, Paris, Paris, Île-de-France, FR, locality, political, administrative_area_level_2, political, administrative_area_level_1, political, country, political
# 2 Paris, Lamar County, Texas, United States, Paris, Lamar County, TX, US, locality, political, administrative_area_level_2, political, administrative_area_level_1, political, country, political
# formatted_address geometry.bounds.northeast.lat geometry.bounds.northeast.lng geometry.bounds.southwest.lat
# 1     Paris, France                      48.90214                      2.469921                      48.81557
# 2    Paris, TX, USA                      33.73838                    -95.435455                      33.61185
# geometry.bounds.southwest.lng geometry.location.lat geometry.location.lng geometry.location_type
# 1                      2.225193              48.85661              2.352222            APPROXIMATE
# 2                    -95.627928              33.66094            -95.555513            APPROXIMATE
# geometry.viewport.northeast.lat geometry.viewport.northeast.lng geometry.viewport.southwest.lat geometry.viewport.southwest.lng
# 1                        48.90214                        2.469921                        48.81557                        2.225193
# 2                        33.73838                      -95.435455                        33.61185                      -95.627928
# place_id               types
# 1 ChIJD7fiBh9u5kcRYJSMaMOCCwQ locality, political
# 2 ChIJmysnFgZYSoYRSfPTL2YJuck locality, political
# 
# $status
# [1] "OK"
like image 15
SymbolixAU Avatar answered Oct 20 '22 00:10

SymbolixAU