I am trying to retrieve some cities names from zip codes using Geopy Nominatim. Here is the code:
The problem is that the results I get are not in Italian, but they are:
Do you know how can I get these names in Italian? I would also like to get a more detailed address output. At the moment this is what I get: Susegana, Treviso, Veneto, 31058, Italia I would like something that tells me which is the city, so for example city: Susegana, etc. Thank you, Carlotta. asked 30 Mar, 08:17 Carlotta |
Nominatim can only return Italian names if there are ones in the database (e.g. the name:it hstore tag has a value). You could try to alter your geolocator.geocode call by setting it's language to 'it,en' to get more results in latin script, as the name:en hstore tag is far more often filled with a value than the name:it one. answered 30 Mar, 10:29 Spiekerooger Thanks! I will try this way and let you know if I solved my problem. At the moment if I do city.address I get this output: Susegana, Treviso, Veneto, 31058, Italia I assumed that the city is the first string, but I am not sure. Is there a way to get an output that tells me something like city: Susegana, etc? I tried with addressdetails = True, but it doesn't seem to return what I need. Thanks, Carlotta.
(30 Mar, 10:40)
Carlotta
1
I'm not familiar with geopy, but the city name should be in address.city from the addressdetails. Your city.address looks rather like the display_name returned by Nominatim. Can you get the raw output returned by the geocode function and than see if you have a ['address']['city'] in there?
(30 Mar, 10:56)
Spiekerooger
2
You are totally right! Under city.raw['address']['town'] I found what I needed. Thanks, Carlotta.
(30 Mar, 11:12)
Carlotta
|
Many countries have 5 digit zip codes. Make sure you add the country name to the query, e.g. '12345, Italy'. It also helps to inspect the result for the country and remove any that are not in Italy. answered 30 Mar, 11:57 mtmail Thanks, I had in plan to add it but thank you for the advice anyway!
(30 Mar, 14:04)
Carlotta
|