Search code examples
pythonlocationcoordinatesgeocodingestimation

Getting "best-guess" coordinates from a location name in Python


I'm looking for a way to take a rough location string (ex. "Buddy's Pub in City, State"), and convert it to the best-guess set of coordinates. I've looked at GeoPy and Google's Geocoding API, but they are not exactly what I'm looking for. Any help would be appreciated.


Solution

  • Solved it thanks to @aminrd tip.

    Google Places API is the answer.

    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)
    

    Output looks like

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