Geocoding addresses with googleway: incoherent results

纵饮孤独 提交于 2019-12-10 16:52:35

问题


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,


回答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

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!




回答2:


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.



来源:https://stackoverflow.com/questions/49694452/geocoding-addresses-with-googleway-incoherent-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!