How to get latitude and longitude from address in python
In this article, we will learn to get latitude and longitude from address in Python.
We are using Google’s geocode REST API to fetch latitude and longitude from an address. Geocoding is the process of converting physical addresses into geographic coordinates.
A note to remember: You need an API key for performing the following code. You can review the authentication requirements and the API usage and billing information.
import requests google_map_api_url = 'http://maps.googleapis.com/maps/api/geocode/json' param = { 'address' : 'provide the address here', 'region' : 'india' } req = requests.get(google_map_api_url, params = param) res = req.json() latitude = res['results'][0]['geometry']['location']['lat'] longitude = res['results'][0]['geometry']['location']['lng'] print(latitude, longitude)
Subscribe
Login
Please login to comment
0 Discussion