Search code examples
pythongeocodinghere-apigoogle-geocoderreverse-geocoding

Unable to get correct syntax of python HERE maps reverse geocoding


I want to use HERE api to reverse geocode lat/lon. I am trying as follows :

geohere = here('{}, {}'.format(centroid.GetY(), centroid.GetX()), app_id='WCvPg4vFEghHoPxTaRGM', app_code='yfuHH1jW8oIg7ILD1CER4Q')

But Getting IndexError: list index out of range.

What is the correct syntax? I am able to use the command line api but wanted to use the python one.

Here is the documentation: https://geocoder.readthedocs.io/providers/HERE.html


Solution

  • Since you are trying to reverse geocode, you should add the parameter method with value 'reverse' like so:

    geohere = here('{}, {}'.format(centroid.GetY(), 
                    centroid.GetX()), 
                    app_id='<app_id>', 
                    app_code='<app_code>', 
                    method='reverse')`