PYTHON已知起點(diǎn)經(jīng)緯度及兩點(diǎn)間距離、方位角如何求出終點(diǎn)經(jīng)緯度?

最近遇到一個(gè)需求,使用pyhon 獲取雷達(dá)設(shè)備中的數(shù)據(jù)并解析,將返回?cái)?shù)據(jù)中包含方位角、速度、距離等,需要使用獲得的數(shù)據(jù)來(lái)計(jì)算目標(biāo)經(jīng)緯度!

import math

lon = 23.1090329023218
lat = 113.64838778972626
l_azimuth = 23
l_distance = 0.5  # km


# 已知起點(diǎn)經(jīng)緯度,使用距離與方位角求終點(diǎn)經(jīng)緯度
def get_destination(lat1: float, lon1: float, azimuth: float, distance: float) -> list:
    """
    已知起點(diǎn)經(jīng)緯度,使用距離與方位角求終點(diǎn)經(jīng)緯度
    :param lat1: 已知緯度
    :param lon1: 已知經(jīng)度
    :param azimuth: 已知方位角 °
    :param distance: 已知距離 km
    :return: 終點(diǎn)經(jīng)緯度
    """
    lat1 = math.radians(lat1)
    lon1 = math.radians(lon1)
    azimuth = math.radians(azimuth)
    distance = distance / 6378.1
    lat2 = math.asin(math.sin(lat1) * math.cos(distance) + math.cos(lat1) * math.sin(distance) * math.cos(azimuth))
    lon2 = lon1 + math.atan2(math.sin(azimuth) * math.sin(distance) * math.cos(lat1),
                             math.cos(distance) - math.sin(lat1) * math.sin(lat2))
    lat2 = math.degrees(lat2)
    lon2 = math.degrees(lon2)
    return [lat2, lon2]


print(get_destination(lon, lat, 2.1, l_distance))


# 生成經(jīng)緯度坐標(biāo)并輸出JS語(yǔ)句應(yīng)用到地圖上
for i in range(0, 8):
    z = get_destination(lon, lat, (i + 1) * 45, l_distance)
    print('L.marker([%s, %s]).addTo(map).bindPopup("角度:%d°<br />距離:%f米");' % (z[0], z[1], (i + 1) * 45, l_distance * 1000))

Nginx使用寶典 (tboai.com)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容