Python计算经纬度的方法:

维基百科公式(要求的是公式中的d):

Python:计算经纬度距离

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

相关文章:

  • 2021-12-20
  • 2021-11-11
  • 2022-02-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2021-09-30
猜你喜欢
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
  • 2021-12-14
相关资源
相似解决方案