从 Python 中的位置名称获取 "best-guess" 坐标
Getting "best-guess" coordinates from a location name in Python
我正在寻找一种获取粗略位置字符串(例如 "Buddy's Pub in City, State")并将其转换为最佳猜测坐标集的方法。我看过 GeoPy 和 Google 的地理编码 API,但它们并不是我要找的东西。任何帮助将不胜感激。
感谢@aminrd 提示解决了它。
Google 地方 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'}
我正在寻找一种获取粗略位置字符串(例如 "Buddy's Pub in City, State")并将其转换为最佳猜测坐标集的方法。我看过 GeoPy 和 Google 的地理编码 API,但它们并不是我要找的东西。任何帮助将不胜感激。
感谢@aminrd 提示解决了它。
Google 地方 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'}