I keep getting the following error with the code below: ValueError: math domain error. I can get the distance between two GPS points with other formulas but not with the formula below. Any help would be greatly appreciated,
Thanks,
Gavin
from math import radians, cos, sin, acos
#Formula below does not work :(
#JFK
lat1 = 40.639751
lon1 = -73.778925
#DUB
lat2 = 53.421333
lon2 = -6.270075
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
r = 6373
distance = acos((sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon1 - lon2)) * r)
print(distance)