taga
taga

Reputation: 3885

ValueError: Location should be a string when using Geocoder in Python

Im trying to find city name with geocoder lib. I have float coordinates (lat and lng), I thing I did everything good (I have looked into their documentations) but I always get an error:

ValueError: Location should be a string

Error is in this line:

city_name = geocoder.google([lat, lng], mothod = 'reverse')

This is the code:

import geocoder

lat = 44.0207472303
lng = 20.9033038427
print(lat, lng)

city_name = geocoder.google([lat, lng], mothod = 'reverse')
city_name = str(city_name.city)

print(city_name)

Upvotes: 0

Views: 130

Answers (2)

CodeIt
CodeIt

Reputation: 3618

It is method='reverse' not mothod in this line

city_name = geocoder.google([lat, lng], mothod = 'reverse')

Correct it to:

city_name = geocoder.google([lat, lng], method = 'reverse')

Upvotes: 1

Veniamin
Veniamin

Reputation: 864

As CodeIt mentioned, you should change this line

geocoder.google([lat, lng], mothod = 'reverse')

to this:

geocoder.google([lat, lng], method = 'reverse')

Upvotes: 2

Related Questions