给定经度和纬度,我想找到它所属的国家/大陆。此外,如果可能,其他特征,例如该区域的海拔高度。这个问题回答了但不完全。
from geopy.geocoders import Nominatim
from pprint import pprint
geolocator = Nominatim()
location = geolocator.reverse("52.509669, 13.376294")
pprint(dir(location))
print(location.address)
#No country/continent option
['__class__',
'__delattr__',
'__doc__',
'__eq__',
'__format__',
'__getattribute__',
'__getitem__',
'__hash__',
'__init__',
'__iter__',
'__len__',
'__module__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__sizeof__',
'__slots__',
'__str__',
'__subclasshook__',
'__unicode__',
'_address',
'_point',
'_raw',
'_tuple',
'address',
'altitude',
'latitude',
'longitude',
'point',
'raw']
Potsdamer Platz, Mitte, Berlin, 10117, Deutschland