Python计算经纬度的方法:
维基百科公式(要求的是公式中的d):
Python代码如下(返回结果是单位是:米):
from math import radians,sin,cos,asin,sqrt
def haversine_dis(lon1, lat1, lon2, lat2): #将十进制转为弧度 lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2]) #haversine公式 d_lon = lon2 - lon1 d_lat = lat2 - lat1 aa = sin(d_lat/2)**2 + cos(lat1)*cos(lat2)*sin(d_lon/2)**2 c = 2 * asin(sqrt(aa)) r = 6371 # 地球半径,千米 return c*r*1000
#
参考:(公式推导可参考下面的大神博客)
https://blog.csdn.net/a_a_bb__/article/details/80937508
https://blog.csdn.net/u011001084/article/details/52980834