-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathm13_ort_entfernung.py
More file actions
29 lines (23 loc) · 1019 Bytes
/
Copy pathm13_ort_entfernung.py
File metadata and controls
29 lines (23 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from geopy.geocoders import Nominatim
from geopy import distance
orte = ["Bad Salzuflen", "Dietzenbach", "Bielefeld", "Bielefeld", "Spenge", "Bielefeld",
"Bielefeld", "Schloss Holte-Stukenbrock", "Berlin", "Hannover", "Bielefeld", "Bielefeld"]
orte = set(orte)
ziel = "Bielefeld"
orte.remove(ziel)
# Frage: Welcher Ort aus der Menge der orte
# ist am weitesten vom ziel "VHS Bielefeld" entfernt (Luftlinie)?
geolocator = Nominatim(user_agent="vhs-bielefeld-platz11")
location = geolocator.geocode(ziel)
latlong_ziel = (location.latitude, location.longitude)
# print(latlong_ziel)
distanz_orte = []
for ort in orte:
location = geolocator.geocode(ort)
latlong_ort = (location.latitude, location.longitude)
distanz_ort_geo = distance.distance(latlong_ort, latlong_ziel).km
distanz_ort_gc = distance.great_circle(latlong_ort, latlong_ziel).km
distanz_orte.append((distanz_ort_geo, distanz_ort_gc, ort))
print(*distanz_orte, sep="\n")
print("Größte Entfernung:")
print(max(distanz_orte))