mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-03-28 17:32:36 +01:00
23 lines
650 B
Python
23 lines
650 B
Python
# helper functions to use location data
|
|
# K7MHI Kelly Keeton 2024
|
|
|
|
from geopy.geocoders import Nominatim # pip install geopy
|
|
|
|
def where_am_i(lat=0, lon=0):
|
|
# initialize Nominatim API
|
|
geolocator = Nominatim(user_agent="mesh-bot")
|
|
|
|
location = geolocator.reverse(lat+","+lon)
|
|
address = location.raw['address']
|
|
|
|
# traverse the data
|
|
city = address.get('city', '')
|
|
state = address.get('state', '')
|
|
country = address.get('country', '')
|
|
zipcode = address.get('postcode')
|
|
print('City : ', city)
|
|
print('State : ', state)
|
|
print('Country : ', country)
|
|
print('Zip Code : ', zipcode)
|
|
|
|
return location |