日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

python實現(xiàn)兩個經(jīng)緯度點之間的距離和方位角的方法

系統(tǒng) 2157 0

最近做有關(guān)GPS軌跡上有關(guān)的東西,花費心思較多,對兩個常用的函數(shù)總結(jié)一下,求距離和求方位角,比較精確,歡迎交流!

1. 求兩個經(jīng)緯點的方位角,P0(latA, lonA), P1(latB, lonB)(很多博客寫的不是很好,這里總結(jié)一下)

            
def getDegree(latA, lonA, latB, lonB):
  """
  Args:
    point p1(latA, lonA)
    point p2(latB, lonB)
  Returns:
    bearing between the two GPS points,
    default: the basis of heading direction is north
  """
  radLatA = radians(latA)
  radLonA = radians(lonA)
  radLatB = radians(latB)
  radLonB = radians(lonB)
  dLon = radLonB - radLonA
  y = sin(dLon) * cos(radLatB)
  x = cos(radLatA) * sin(radLatB) - sin(radLatA) * cos(radLatB) * cos(dLon)
  brng = degrees(atan2(y, x))
  brng = (brng + 360) % 360
  return brng

          

2. 求兩個經(jīng)緯點的距離函數(shù):P0(latA, lonA), P1(latB, lonB)

            
def getDistance(latA, lonA, latB, lonB):
  ra = 6378140 # radius of equator: meter
  rb = 6356755 # radius of polar: meter
  flatten = (ra - rb) / ra # Partial rate of the earth
  # change angle to radians
  radLatA = radians(latA)
  radLonA = radians(lonA)
  radLatB = radians(latB)
  radLonB = radians(lonB)
 
  pA = atan(rb / ra * tan(radLatA))
  pB = atan(rb / ra * tan(radLatB))
  x = acos(sin(pA) * sin(pB) + cos(pA) * cos(pB) * cos(radLonA - radLonB))
  c1 = (sin(x) - x) * (sin(pA) + sin(pB))**2 / cos(x / 2)**2
  c2 = (sin(x) + x) * (sin(pA) - sin(pB))**2 / sin(x / 2)**2
  dr = flatten / 8 * (c1 - c2)
  distance = ra * (x + dr)
  return distance

          

以上這篇python實現(xiàn)兩個經(jīng)緯度點之間的距離和方位角的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 甘泉县| 汕头市| 土默特右旗| 佳木斯市| 砀山县| 九龙县| 无极县| 安仁县| 万源市| 武功县| 潜山县| 儋州市| 贡觉县| 齐河县| 紫金县| 芦溪县| 白沙| 临桂县| 尼玛县| 饶阳县| 彩票| 曲阜市| 藁城市| 西乌珠穆沁旗| 浦县| 达日县| 澄城县| 边坝县| 襄汾县| 平阳县| 福海县| 江陵县| 隆化县| 苏尼特左旗| 福鼎市| 舟曲县| 旌德县| 郁南县| 临朐县| 铁岭市| 衡阳县|