0

Im using Python's geocoder lib , and Im trying to find city names based on lat and lng. The problem is that I always get None values, any ideas why?

import geocoder

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

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

print(city_name) #None
5
  • Do you have API key for the API ? Commented Jul 26, 2019 at 8:52
  • No, I did not know what I need that. How can I get that? Commented Jul 26, 2019 at 8:54
  • Here you go developers.google.com/maps/documentation/geocoding/… Commented Jul 26, 2019 at 8:55
  • Geocoder documentation says that It does not requires api key. Also I have saw some codes on this website that work without api Commented Jul 26, 2019 at 8:58
  • This question is actually a duplicate of Using my Google Geocoding API key with Python geocoder. Commented Jul 26, 2019 at 9:08

1 Answer 1

1

In order for you to use Google's geocoding API with gecoder, you need to have the Google API keys set in the environment variables. See here.

To get the Geocoding API keys, you must first activate the API in the Google Cloud Platform Console and obtain the proper authentication credentials. You can get API credentials here,

https://cloud.google.com/maps-platform/#get-started

After getting the API key, you need to add the following code in order to use it.

import os

os.environ["GOOGLE_API_KEY"] = "API_KEY"

Source

Sign up to request clarification or add additional context in comments.

1 Comment

um, is this free?

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.