Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jupyter-naas
GitHub Repository: jupyter-naas/awesome-notebooks
Path: blob/master/Geopy/Geopy_Get_address_from_coordinates.ipynb
2973 views
Kernel: Python 3

Geopy.png

Geopy - Get address from coordinates

Give Feedback | Bug report

Tags: #geopy #coordinates #address #navigation #snippet

Last update: 2023-07-28 (Created: 2023-07-28)

Description: This notebook demonstrates how to utilize Geopy to convert a location(latitude and longitude) to its corresponding address.

Input

Import libraries

from geopy.geocoders import Nominatim

Setup variables

  • latitude: This variable represents the position of a point on Earth's surface in terms of degrees north or south of the equator.

  • longitude: This variable represents the position of a point on Earth's surface in terms of degrees east or west of the Prime Meridian.

# The variables `latitude` and `longitude` are utilized to store geographical coordinates. latitude = 42.6641527 longitude = 23.2881605

Model

Get address

geolocator = Nominatim(user_agent="geopy_exercise") location = geolocator.reverse((latitude, longitude), exactly_one=True, language="en") address = location.address if location else "Address not found"

Output

Display result

print("Address:", address)