w3resource

Python GeoPy Package: Find the location address of a specified latitude and longitude

Default Options Object (Nominatim API): Exercise-5 with Solution

Write a Python program to find the location address of a specified latitude and longitude using Nominatim API and Geopy package.

Sample Solution:

Python Code:

from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="geoapiExercises")
lald = "47.470706, -99.704723"
print("Latitude and Longitude:",lald)
location = geolocator.geocode(lald)
print("Location address of the said Latitude and Longitude:")
print(location)
lald = "34.05728435, -117.194132331602"
print("\nLatitude and Longitude:",lald)
location = geolocator.geocode(lald)
print("Location address of the said Latitude and Longitude:")
print(location)
lald = "38.8976998, -77.0365534886228"
print("\nLatitude and Longitude:",lald)
location = geolocator.geocode(lald)
print("Location address of the said Latitude and Longitude:")
print(location)
lald = "55.7558° N, 37.6173° E"
print("\nLatitude and Longitude:",lald)
location = geolocator.geocode(lald)
print("Location address of the said Latitude and Longitude:")
print(location)
lald = "35.6762° N, 139.6503° E"
print("\nLatitude and Longitude:",lald)
location = geolocator.geocode(lald)
print("Location address of the said Latitude and Longitude:")
print(location)
lald = "41.9185° N, 45.4777° E"
print("\nLatitude and Longitude:",lald)
location = geolocator.geocode(lald)
print("Location address of the said Latitude and Longitude:")
print(location)

Sample Output:

Latitude and Longitude: 47.470706, -99.704723
Location address of the said Latitude and Longitude:
399, Stanford Avenue, Bowdon, Wells County, North Dakota, 58418, USA

Latitude and Longitude: 34.05728435, -117.194132331602
Location address of the said Latitude and Longitude:
Esri Building C, 380, New York Street, Esri Inc., Redlands, San Bernardino County, California, 92373, USA

Latitude and Longitude: 38.8976998, -77.0365534886228
Location address of the said Latitude and Longitude:
White House, 1600, Pennsylvania Avenue Northwest, Golden Triangle, Washington, D.C., 20500, USA

Latitude and Longitude: 55.7558° N, 37.6173° E
Location address of the said Latitude and Longitude:
Государственный исторический музей, 1, Красная площадь, Китай-город, Тверской район, Центральный административный округ, Москва, ЦФО, 109012, РФ

Latitude and Longitude: 35.6762° N, 139.6503° E
Location address of the said Latitude and Longitude:
高円寺, 杉並区, 東京都, 関東地方, 168-0063, 日本

Latitude and Longitude: 41.9185° N, 45.4777° E
Location address of the said Latitude and Longitude:
გვირაბის ქუჩა (Gvirabi St), თელავი, კახეთი, 2200, საქართველო

Python Code Editor:


Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program to find the latitude and longitude of a given location using Nominatim API and Geopy package.
Next: Write a Python function to get the city, state and country name of a specified latitude and longitude using Nominatim API and Geopy package.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/python-exercises/geopy/python-geopy-nominatim_api-exercise-5.php