geocoding.py 695 B

12345678910111213141516171819202122232425
  1. import requests
  2. # Base Url for geocoding
  3. url = "https://us1.locationiq.com/v1/search.php"
  4. address = input("Input the address: ")
  5. #Your unique private_token should replace value of the private_token variable.
  6. #To know how to obtain a unique private_token please refer the README file for this script.
  7. private_token = "Your_private_token"
  8. data = {
  9. 'key': private_token,
  10. 'q': address,
  11. 'format': 'json'
  12. }
  13. response = requests.get(url, params=data)
  14. latitude = response.json()[0]['lat']
  15. longitude = response.json()[0]['lon']
  16. print(f"The latitude of the given address is: {latitude}")
  17. print(f"The longitude of the given address is: {longitude}")
  18. print("Thanks for using this script")