【问题标题】:The country belonging to a location (python)?属于某个位置的国家/地区(python)?
【发布时间】:2017-08-17 07:21:21
【问题描述】:

通过

Given the lat/long coordinates, how can we find out the city/country?

我试图从坐标中获取信息,并且正如 Farsheed 在 python 中所写的那样。但是我可以只得到国家作为答案吗,是否存在这样的属性来提供“位置”变量?

【问题讨论】:

  • 只要你有数据,它就可以给你任何你想要的东西。
  • location.raw['address']['country'] 中没有你想要的吗?
  • 这就是我要找的,谢谢!

标签: python location geopy


【解决方案1】:
>>> 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', ...}

【讨论】:

  • 问题问如何才能得到国家。更新您的答案以演示如何。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-20
  • 2018-04-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多