Search code examples
rgoogle-geocodergoogle-geocoding-api

Geocode failed with status OVER_QUERY_LIMIT R studio


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.


Solution

  • 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.