4

I am trying to geocode addresses on Google Maps using the google_geocode function from the package googleway in R. I am using a key obtained from Google that allows me to go over the 2500/day limit (and being charged for that). I have different types of problems, mainly due to the way the addresses I use are written, but there is one issue that I would like to ask here: how is it possible that I sometimes get no results querying with googe_geocode, but if I type the same address string on http://www.google.com/maps/ it does return a result?

My example:

address="AVENDAÑO, 30-32 VITORIA-GASTEIZ 01008, ES"
# the address I want to geocode. Its format is "street, number, city postcode, country" in a single string.
google_geocode(address=address,key=mykey) # I write the right key as mykey.
# I get no results:
$results
list()
$status
[1] "ZERO_RESULTS"

But, if search for exactly the same address string in Google Maps, I get the right location (showing that this is Abendaño Kalea in Vitoria, Spain):

https://www.google.com/maps/place/Abenda%C3%B1o+Kalea,+30,+01008+Vitoria-Gasteiz,+Araba/@42.8451894,-2.6855022,17z/data=!3m1!4b1!4m5!3m4!1s0xd4fc213d775d83d:0xc2a5f2ffa8721c2a!8m2!3d42.8451855!4d-2.6833135

Can anyone explain what may be going on? Maybe some staff from Google Maps or Google Geocoding API may help? Thanks a lot,

Javier
  • 41
  • 5
  • I had the same experience but also have no idea why this happens. – DatamineR Apr 06 '18 at 14:00
  • have you tried the `places` api? `google_places(search_string = address, key = )`. The data behind Google's Map and the data they release through their APIs aren't always the same. I don't know why. – SymbolixAU Apr 10 '18 at 22:01
  • Places are not detailed enough for my purposes, but you are right (as also suggested by xomena below) that the problem is due to Maps and APIs not using the same data. Thanks. – Javier Apr 11 '18 at 15:32

2 Answers2

1

Note that Google knows this street as 'ABENDAÑO, 30-32 VITORIA-GASTEIZ 01008, ES', so the B and V letters are important. I know that in Spanish language this is the same sound, but probably Google expects exact match.

According to the documentation:

Specify addresses in accordance with the format used by the national postal service of the country concerned.

source: https://developers.google.com/maps/faq#geocoder_queryformat

On the Correos.es I can see that the official street name is ABENDAÑO as shown in the following screenshot

enter image description here

So just use the following request to get results:

https://maps.googleapis.com/maps/api/geocode/json?address=ABENDA%C3%91O%2C%2030-32%20VITORIA-GASTEIZ%2001008%2C%20ES&key=YOUR_API_KEY

Or the same thing in geocoder tool:

https://google-developers.appspot.com/maps/documentation/utils/geocoder/#q%3DABENDA%25D1O%252C%252030-32%2520VITORIA-GASTEIZ%252001008%252C%2520ES

I hope this helps!

xomena
  • 31,125
  • 6
  • 88
  • 117
  • Thanks for the reply, but I think that it may miss the point. Of course, if I could write all the addresses I need to geocode in a normalised way, Google would deal with them properly. But what I have experienced is that in some cases (the Avendaño/Abendaño one is just an example) while Google Maps reinterprets the non-exact address correctly and provides an answer, the API doesn't and returns "ZERO_RESULTS". – Javier Apr 10 '18 at 21:24
  • You should understand that Google Maps web site and Google Maps API are different products managed by different teams at Google. There is no guarantee that they work exactly the same. – xomena Apr 10 '18 at 22:01
  • Yes, that seems to be the case. I was not aware of the difference between them. Thanks a lot. – Javier Apr 11 '18 at 15:31
1

I think it is likely that is due to encoding issues. I have had this happen when trying to geolocate addresses with "Ñ". Doing this worked for me:

string <- "AVENDAÑO, 30-32 VITORIA-GASTEIZ 01008, ES"
Encoding(string) <- "UTF-8"
google_geocode(string, key = key)

Since google changed their pricing scheme now you need to have an API key.

Ilde Mauriaca
  • 130
  • 1
  • 6