"Dabei ist w im Bogenmaß einzusetzen"
Verfasst: Sonntag 16. Juni 2019, 17:12
Hallo!
Versuche gerade, die Vincenty-Formel in Python zu übersetzen. Bis zum groben Abstand "D" sieht es ganz vielversprechend aus, aber dazu fehlt noch eine Angabe von "w" im Bogenmaß. Wie kann ich einen Wert "w" "im Bogenmaß einsetzen"?
Hier der vorläufige Code:
Grüße
Strawk
Versuche gerade, die Vincenty-Formel in Python zu übersetzen. Bis zum groben Abstand "D" sieht es ganz vielversprechend aus, aber dazu fehlt noch eine Angabe von "w" im Bogenmaß. Wie kann ich einen Wert "w" "im Bogenmaß einsetzen"?
Hier der vorläufige Code:
Code: Alles auswählen
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 26 10:45:34 2019
@author: Karl Kraft
"""
from __future__ import print_function, division
import numpy as np
import math
from math import radians
def vincenty(lat1, lat2, lon1, lon2):
""" calculates the distance in kilometers between two geographical points
"""
'''
lat1 = radians(lat1)
lat2 = radians(lat2)
lon1 = radians(lon1)
lon2 = radians(lon2)
'''
f = 1/298.257223563
# print(f)
a = 6378.137
F = ((lat1+lat2)/2)
G = ((lat1-lat2)/2)
l = ((lon1-lon2)/2)
S = ((math.sin(G))**2) * ((math.cos(l))**2) + ((math.cos(F))**2) * ((math.sin(l))**2)
C = ((math.cos(G))**2) * ((math.cos(l))**2) + ((math.sin(F))**2) * ((math.sin(l))**2)
w = np.arctan(math.sqrt(S/C))
D = 2 * 0.0151440 * a
print(w)
return D
if __name__ == "__main__":
'''
westlicher Ort: Position 1
östlicher Ort: Position 2
'''
'''
# Madrid (1) - Budapest (2)
lat1 = 40.4167754
lat2 = 47.497912
lon1 = -3.7037902
lon2 = 19.040235
'''
'''
# New York (1) - Aachen (2)
lat1 = 40.712784
lat2 = 50.7753455
lon1 = -74.005941
lon2 = 6.0838868
'''
'''
# Berlin (1) - Pretoria (2)
lat1 = 52.520007
lat2 = -25.746111
lon1 = 13.404954
lon2 = 28.188056
'''
# Pretoria (1) - Moskau (2)
lat1 = -25.746111
lat2 = 55.755826
lon1 = 28.188056
lon2 = 37.617300
'''
# Aachen (1) - Mönchengladbach (2)
lat1 = 50.7753455
lat2 = 51.1804572
lon1 = 6.0838868
lon2 = 6.4428041
'''
result = vincenty(lat1, lat2, lon1, lon2)
print("km: %.1f" % (result), "\t")
Strawk