GEOMAPpy/GEOMAPpy.py

26 lines
797 B
Python
Raw Normal View History

2025-01-19 21:26:13 +01:00
#!/usr/bin/env python3
import folium
from geopy.geocoders import Nominatim
# Fonction pour obtenir la latitude et la longitude à partir d'une adresse
def get_location(address):
geolocator = Nominatim(user_agent="GEOMAPpy")
location = geolocator.geocode(address)
return location.latitude, location.longitude
adresse = input("Entrez une adresse : ")
2025-01-20 00:07:14 +01:00
lat, lon = get_location(adresse)
2025-01-19 21:26:13 +01:00
# Créer une carte centrée autour de la localisation
2025-01-20 00:07:14 +01:00
m = folium.Map(location=[lat, lon], zoom_start=15)
2025-01-19 21:26:13 +01:00
# Ajouter un marqueur à la carte
2025-01-20 00:07:14 +01:00
folium.Marker(
[lat, lon],
popup="<h2>"+adresse+"</h2><h4>"+str([lat, lon])+"</h4>"
).add_to(m)
2025-01-19 21:26:13 +01:00
# Sauvegarder la carte dans un fichier HTML et afficher les coordonnées
m.save("map.html")
2025-01-20 00:07:14 +01:00
print(f"Coordonnées de l'adresse {adresse} : {lat}, {lon}")