সেই স্থানের ভৌগলিক স্থানাঙ্কগুলি পেতে যা সেই স্থানের দ্রাঘিমাংশ এবং অক্ষাংশ আমরা ব্যবহার করতে পারি google Maps geocoding api৷
প্রয়োজন
একটি স্থানের স্থানাঙ্ক পেতে, আমাদের জিওকোডিং এপিআই প্রয়োজন এবং আপনি নীচের লিঙ্ক থেকে এটি পেতে পারেন:
https://developers.google.com/maps/documentation/geocoding/get-api-key
api_key ছাড়াও, আমরা পাইথন
ব্যবহার করতে যাচ্ছি- অনুরোধ মডিউল (স্থানাঙ্কগুলি আনুন)
- Json মডিউল (রূপান্তরের জন্য)।
নিচে একই অর্জন করার জন্য প্রোগ্রাম রয়েছে:
# Import required library
import requests
import json
#Enter the place name
place = input("Please enter place name: ")
#Place your google map API_KEY to a variable
apiKey = 'YOUR_API_KEY'
#Store google geocoding api url in a variable
url = 'https://maps.googleapis.com/maps/api/geocode/json?'
# call get method of request module and store respose object
r = requests.get(url + 'address =' + place + '&key =' + apiKey)
#Get json format result from the above response object
res = r.json()
#print the value of res
print(res) আউটপুট
Please enter place name: Dehradun
{'results': [{'address_components': [{'long_name': 'Dehradun', 'short_name': 'Dehradun', 'types': ['locality', 'political']}, {'long_name': 'Dehradun', 'short_name': 'Dehradun', 'types': ['administrative_area_level_2', 'political']}, {'long_name': 'Uttarakhand', 'short_name': 'UK', 'types': ['administrative_area_level_1', 'political']}, {'long_name': 'India', 'short_name': 'IN', 'types': ['country', 'political']}], 'formatted_address': 'Dehradun, Uttarakhand, India', 'geometry': {'bounds': {'northeast': {'lat': 30.4041936, 'lng': 78.1089305}, 'southwest': {'lat': 30.2466633, 'lng': 77.92533879999999}}, 'location': {'lat': 30.3164945, 'lng': 78.03219179999999}, 'location_type': 'APPROXIMATE', 'viewport': {'northeast': {'lat': 30.4041936, 'lng': 78.1089305}, 'southwest': {'lat': 30.2466633, 'lng': 77.92533879999999}}}, 'place_id': 'ChIJr4jIVsMpCTkRmYdRMsBiNUw', 'types': ['locality', 'political']}], 'status': 'OK'}