从Python中的位置名称获取“最佳猜测”坐标

时间:2019-12-18 21:53:23

标签: python location coordinates geocoding estimation

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

1 个答案:

答案 0 :(得分:-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'}
相关问题