Python 经纬度,偏航角,距离计算

参考https://blog.csdn.net/ETNJTOTG/article/details/84130971

Python 经纬度,偏航角,距离计算_第1张图片

import numpy as np

def lonlat2Azimuth(lonA, latA, lonB, latB):

    toRad = np.pi / 180

    cosC = np.cos((90 - latB) * toRad) * np.cos((90 - latA) * toRad) + np.sin((90 - latB) * toRad) * np.sin((90 - latA) * toRad) * np.cos((lonB - lonA) * toRad)
    sinC = np.sqrt(1 - np.square(cosC))
    sinA = np.sin((90 - latB) * toRad) * np.sin((lonB - lonA) * toRad) / sinC

    if latA > latB:
        return  180 - np.arcsin(sinA) / toRad
    return  np.arcsin(sinA) / toRad

def lonlat2dist(lonA, latA,lonB, latB):
    R = 6371393
    toRad = np.pi / 180

    cosC = np.cos((90 - latB) * toRad) * np.cos((90 - latA) * toRad) + np.sin((90 - latB) * toRad) * np.sin((90 - latA) * toRad) * np.cos((lonB - lonA) * toRad)

    C = np.arccos(cosC)
    return C * R

def distAzimuth2lonlat(lonA, latA, dist, azimuth):
    R = 6371393
    toRad = np.pi / 180

    c = dist / R / toRad
    a = np.arccos(np.cos((90 - latA)*toRad) * np.cos(c * toRad) + np.sin((90 - latA) * toRad) * np.sin(c * toRad) * np.cos(azimuth * toRad))
    latB = 90 - a / toRad
    C = np.arcsin(np.sin(c*toRad) * np.sin(azimuth *toRad) / np.sin(a))
    lonB = lonA + C / toRad

    return  (lonB,latB)


你可能感兴趣的:(tools,cv,python,python,numpy,机器学习)