I have some longitude latitude coordinates and I want to convert it to a specific address using Python. Do you know how to do that? Thank you I am new here.
Get address from given coordinate using python
Asked Answered
Have a look at geopy –
Subcritical
Related (maybe dup) - #12943394 –
Kollwitz
The method that you mean called Reverse Geocode. You can use Nominatim (OSM) for free geocode service
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="specify_your_app_name_here")
location = geolocator.reverse("52.509669, 13.376294")
print(location.address)
Or if you wanna get better results, you can use Google Geocode service that requires API Key
from geopy.geocoders import GoogleV3
geolocator = GoogleV3(api_key='Your_API_Key')
location = geolocator.reverse("52.509669, 13.376294")
print(location.address)
use geopy, this is a script I made myself, you can use it
from geopy.geocoders import Nominatim
from os import system, name
those are your imports. then you would want to define a clear function, this will come in play later
def clear():
if name == 'nt':
_ = system('cls')
else:
_ = system('clear')
then define the useragent:
geolocator = Nominatim(user_agent="coordinateconverter")
i have it set as coordinateconverter because this is my project name
then define your address:
address = '42.2817131, -83.7465425'
that was the ann arbor hands on museum address
then actually convert it:
location = geolocator.reverse(address)
print(location)
this is untested code so it may not work, but it should
What is the
clear()
function used for? It’s not used by the code, only defined. –
Istic © 2022 - 2024 — McMap. All rights reserved.