How to get lat long from address

Getting lat long from address

What is latitude and longitude

latitude and longitude is basicaly pin point of locatoin , like every actual House its address which is include the all address as number, street, city, etc.. and every single point of the surface of earth could be specified by the lat long coordinate.

In below I am showing the manual process of Google Map attached screenshot. You can find the lat long when you search location in Google Maps.



As you can see actual Lat Long of address in Google Map and same thing you can generate lat long with programming language.

I will show all details with python language and you can use anyone programming language just follow the below point

Step 1 : Generate Google Map API

Google Map API is very important to Developer if don't know How to get google api key . I will show you process of generate Google Map API key step by step also you can read about Google API key

  • Click on below link for open google developers page for generate google api key

  • Generate Google API KEY

    After click on link, You will get the Google API Developers page and see the all details .I am attaching the screenshot in below and you can see process of generate google api key


    Screenshot 1 :

    I have highlighted the tabs where you need to click on this



    Screenshot 2 :

    After click on credentials page you will go in next page as google api and services dashboard and just you need to click on credentials tab on left side bar . then click on create credentials tab on top



    Screenshot 3 :

    After the click on create credentials tab button on top then you will get popup screen and finally you will get the google api key



    Once generate google api key then need to keep KEY with google map url , below full details with example

    Step 2 : Define Google Map URL and KEY


    Example of generate Latitude and longitude


    import requests import json GOOGLE_API_KEY = "" address = "M G Road Gurgaon" google_map_url = "https://maps.googleapis.com/maps/api/geocode/json?address="+address+"&key=GOOGLE_API_KEY" resp = response._content res = json.loads(resp) print res { u 'results': [{ u 'address_components': [{ u 'long_name': u 'Mehrauli-Gurgaon Road', u 'short_name': u 'MG Road', u 'types': [u 'route'] }, { u 'long_name': u 'Gurugram', u 'short_name': u 'Gurugram', u 'types': [u 'locality', u 'political'] }, { u 'long_name': u 'Gurgaon', u 'short_name': u 'Gurgaon', u 'types': [u 'administrative_area_level_2', u 'political'] }, { u 'long_name': u 'Haryana', u 'short_name': u 'HR', u 'types': [u 'administrative_area_level_1', u 'political'] }, { u 'long_name': u 'India', u 'short_name': u 'IN', u 'types': [u 'country', u 'political'] } ], u 'formatted_address': u 'Mehrauli-Gurgaon Rd, Gurugram, Haryana, India', u 'geometry': { u 'bounds': { u 'northeast': { u 'lat': 28.4848552, u 'lng': 77.1231327 }, u 'southwest': { u 'lat': 28.4634884, u 'lng': 77.0333178 } }, u 'location': { u 'lat': 28.47905, u 'lng': 77.0773237 }, u 'location_type': u 'GEOMETRIC_CENTER', u 'viewport': { u 'northeast': { u 'lat': 28.4848552, u 'lng': 77.1231327 }, u 'southwest': { u 'lat': 28.4634884, u 'lng': 77.0333178 } } }, u 'place_id': u 'Ei1NZWhyYXVsaS1HdXJnYW9uIFJkLCBHdXJ1Z3JhbSwgSGFyeWFuYSwgSW5kaWEiLiosChQKEgllF- S3FR4NORHupNzwtQv3UxIUChIJWYjjgtUZDTkRHkvG5ehfzwI', u 'types': [u 'route'] }], u 'status': u 'OK' } location = res['results'][0]['geometry']['location'] print location {u'lat': 28.47905, u'lng': 77.0773237} lat = location['lat'] lon = location['lng'] print "latitude : ", lat , ", longitude : ",lon Final result will be : latitude : 28.47905 , longitude : 77.0773237

    Finally you will get the lat long from address in python if you have any doubt please comment



    pagination like gmail in jquery

    Post a Comment

    0 Comments