python-3.xreversegeocoder

Introducing API key in reverse method (geocoder python library)


I would appreciate some help with this: I am trying to get county and country given a geolocalization using reverse method of geocoder python library. It asks me to include an API key, once I get the token/key from my account in mapbox, how could I add it to my query?

import geocoder

g = geocoder.mapbox([53.3887213, -2.732602113], method='reverse')
print(g.county)
print(g.country)

Thank you very much in advance!


Solution

  • Solution:

    import geocoder
    
    latlng = [45.3, -105.1]
    g = geocoder.mapbox(latlng, 
                        key='ACCESS_MAPBOX_TOKEN', 
                        method='reverse')
    g.json