Address → Latitude / Longitude Latitude / Longitude → Address can be converted
This time, when I ran it on virtualenv, I got a UnicodeEncodeError, so I did a pip install directly to Anaconda2. By the way, the default encoding is utf-8. Reference site → Change the default encoding of python to utf-8
# -*- coding: utf-8 -*-
from geopy.geocoders import Nominatim
geolocator = Nominatim()
location = geolocator.geocode("Tokyo Station")
print (location.latitude, location.longitude)
# (35.68018575, 139.768196161308)
location = geolocator.reverse("35.68018575, 139.768196161")
print (location.address)
#Tokyo Station,Sotobori-dori,Chuo-ku,Tokyo, 100-6633,Japan
By the way, I sometimes get a timeout error.
Recommended Posts