【问题标题】:Getting "best-guess" coordinates from a location name in Python [closed]从 Python 中的位置名称获取“最佳猜测”坐标 [关闭]
【发布时间】:2019-12-18 21:53:23
【问题描述】:

我正在寻找一种方法来获取粗略的位置字符串(例如“州城市的好友酒吧”),并将其转换为最佳猜测坐标集。我查看了 GeoPy 和 Google 的 Geocoding API,但它们并不是我想要的。任何帮助将不胜感激。

【问题讨论】:

标签: python location coordinates geocoding estimation


【解决方案1】:

感谢@aminrd 提示,解决了这个问题。

Google Places API 就是答案。

import googlemaps
API_KEY = "your google API key goes here"
gmaps = googlemaps.Client(key=API_KEY)
place_result = gmaps.find_place(input='Buddy\'s Pub in City, State', input_type='textquery', fields=["geometry/location"])
print(place_result)

输出看起来像

{'candidates': [{'geometry': {'location': {'lat': XX.2804533, 'lng': -XXX.1195808}}}], 'status': 'OK'}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-18
    • 2012-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-17
    • 2012-05-27
    • 1970-01-01
    相关资源
    最近更新 更多