python計算GPS兩點之間的中間點
import mathdef midpoint(x1, y1, x2, y2):
Input values as degrees
Convert to radians
lat1 = math.radians(x1) lon1 = math.radians(x2) lat2 = math.radians(y1) lon2 = math.radians(y2) bx = math.cos(lat2) * math.cos(lon2 - lon1) by = math.cos(lat2) * math.sin(lon2 - lon1) lat3 = math.atan2(math.sin(lat1) + math.sin(lat2), \ math.sqrt((math.cos(lat1) + bx) * (math.cos(lat1) \ + bx) + by**2)) lon3 = lon1 + math.atan2(by, math.cos(lat1) + Bx) return [round(math.degrees(lat3), 2), round(math.degrees(lon3), 2)]
</pre>
本文由用戶 pythopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!