属于某个位置的国家/地区(蟒蛇)?



via

给定经纬度坐标,我们如何找出城市/国家?

我试图从坐标中获取信息,正如 Farsheed 用 python 编写的那样,它有效。但是我可以只得到国家作为答案吗,是否存在这样的属性来给出"位置"变量?

>>> from geopy.geocoders import Nominatim
>>> geolocator = Nominatim(user_agent="specify_your_app_name_here")
>>> location = geolocator.reverse("52.509669, 13.376294")
>>> print(location.address)
Potsdamer Platz, Mitte, Berlin, 10117, Deutschland, European Union
>>> print((location.latitude, location.longitude))
(52.5094982, 13.3765983)
>>> print(location.raw)
{'place_id': '654513', 'osm_type': 'node', ...}

最新更新