File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ## Geocoding Script
2+
3+ ### This script takes an address and return its latitude and longitude.This process is called geocoding
4+
5+ #### I have used the locationiq website's geocoding api inorder to solve this problem.
6+
7+ #### To be able to use this script you have to create a * free account* at https://locationiq.com/ and obtain your * private token* .
8+
9+ #### Remember, * don'tshare* your private token with anyone.
Original file line number Diff line number Diff line change 1+ import requests
2+
3+ # Base Url for geocoding
4+ url = "https://us1.locationiq.com/v1/search.php"
5+
6+ address = input ("Input the address: " )
7+
8+ #Your unique private_token should replace value of the private_token variable.
9+ #To know how to obtain a unique private_token please refer the README file for this script.
10+ private_token = "6c0a7b6f14b7cb"
11+
12+ data = {
13+ 'key' : private_token ,
14+ 'q' : address ,
15+ 'format' : 'json'
16+ }
17+
18+ response = requests .get (url , params = data )
19+
20+ latitude = response .json ()[0 ]['lat' ]
21+ longitude = response .json ()[0 ]['lon' ]
22+
23+ print (f"The latitude of the given address is: { latitude } " )
24+ print (f"The longitude of the given address is: { longitude } " )
25+ print ("Thanks for using this script" )
Original file line number Diff line number Diff line change 1+ certifi == 2020.6.20
2+ chardet == 3.0.4
3+ idna == 2.10
4+ requests == 2.24.0
5+ urllib3 == 1.25.10
You can’t perform that action at this time.
0 commit comments