0

I want to create a data frame in R with name of districts and their long and lat. For this purpose, I gave the command:

>locations_df <- mutate_geocode(cities_df, district)

This commands used the maps.googleapis.com for the purpose of geocoding, but for my 13 districts I am getting NA error. One of the error is pasted below:

geocode failed with status OVER_QUERY_LIMIT, location = "Sukkur" 

How can I provide the geocode for missing values? I checked the name of missed cities on google map for spelling error but no such error was seen.

Thank you for the help.

timbo
  • 13,244
  • 8
  • 51
  • 71
Nido
  • 55
  • 1
  • 1
  • 10

1 Answers1

1

Honestly your best bet may be to try running the query again. The results seem pretty idiosyncratic as far as I can tell (possibly related to dynamic IPs over WiFi?). These are my results from just now.

df %>% mutate_geocode(address)

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

So it failed for me too. I checked the queries I had left, then added "Paris" to check its results.

geocodeQueryCheck()
2499 geocoding queries remaining.

df
  address
1  Sukkur

df[2,1]<-"Paris"
df %>% mutate_geocode(address)

Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Sukkur&sensor=false
Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Paris&sensor=false
  address       lon      lat
1  Sukkur 68.822808 27.72436
2   Paris  2.352222 48.85661

And now it works!

The issue may be helped by obtaining a Google Maps API key as this question suggests, which you can use if you install the GitHub version of ggmap.

The other option is to iterate through requests as an answer here suggests.

Esther
  • 1,115
  • 1
  • 10
  • 15