0

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)
2
  • 2
    It is method='reverse' not mothod in line city_name = geocoder.google([lat, lng], mothod = 'reverse') Commented Jul 26, 2019 at 8:41
  • Thanks, that was stupid from me, but I always get None as result Commented Jul 26, 2019 at 8:47

2 Answers 2

2

As CodeIt mentioned, you should change this line

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

to this:

geocoder.google([lat, lng], method = 'reverse')
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, that was stupid from me, but I always get None as result
1

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')

4 Comments

Thanks, that was stupid from me, but I always get None as result
@taga That is a different question.
Please check it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.