forked from wunnox/python_grundlagen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUB7.4_distanzen.py
More file actions
executable file
·39 lines (33 loc) · 1005 Bytes
/
Copy pathUB7.4_distanzen.py
File metadata and controls
executable file
·39 lines (33 loc) · 1005 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
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python
# -*- coding: utf-8 -*-
##############################################
#
# Name: UB7.4_distanzen.py
#
# Author: Peter Christen
#
# Version: 1.0
#
# Date: 12.01.2016
#
# Purpose: Liest Adressen ein ung gibt deren
# Geo-Positionen aus und berechnet
# die Distanz zwischen den beiden.
#
##############################################
from geopy.geocoders import Nominatim
from geopy.distance import vincenty
# Variabeln
geolocator = Nominatim()
# Adresse bestimmen
digizh = geolocator.geocode("Limmatstrasse 50, 8005 Zürich")
digibe = geolocator.geocode("Bubenbergplatz 11, 3011 Bern")
# Längen und Breitengrade auslesen
digizhkoord = (digizh.latitude, digizh.longitude)
digibekoord = (digibe.latitude, digibe.longitude)
# Distanz berechnen
distanz = vincenty(digizhkoord, digibekoord).km
# Angaben ausgeben
print "Standort Zürich Koordinaten: ", digizhkoord
print "Standort Bern Koordinaten : ", digibekoord
print "Distanz dazwischen : ", distanz, "km"