# # Torbert, 22 Sept 2014 # White (ed), 5 Oct 2016 # from math import pi , acos , sin , cos # def calcd(y1,x1, y2,x2): # # y1 = lat1, x1 = long1 # y2 = lat2, x2 = long2 # all assumed to be in decimal degrees # if (and only if) the input is strings # use the following conversions y1 = float(y1) x1 = float(x1) y2 = float(y2) x2 = float(x2) # R = 3958.76 # miles = 6371 km # y1 *= pi/180.0 x1 *= pi/180.0 y2 *= pi/180.0 x2 *= pi/180.0 # # approximate great circle distance with law of cosines # return acos( sin(y1)*sin(y2) + cos(y1)*cos(y2)*cos(x2-x1) ) * R # # # end of file #