✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

❤️

在现代导航和地理信息系统中,计算两个地点之间的距离是一个重要的问题。无论是为了规划旅行路线,还是为了测量两个地点之间的实际距离,我们都需要一种可靠的方法来计算距离。在这篇文章中,我们将介绍一种基于WGS84椭球恒向线距离的方法,用于计算沿纬度和经度路径行驶的距离。

WGS84是一种广泛使用的地球椭球体模型,被用于全球定位系统(GPS)和地理信息系统(GIS)中。它是由美国国防部制定的一种地球模型,用于在三维空间中表示地球的形状。WGS84椭球体模型基于地球的尺寸和形状,通过使用经度和纬度坐标来表示地球上的位置。

在计算沿纬度和经度路径行驶的距离时,我们需要考虑地球的曲率和椭球形状。由于地球并非完全是一个球体,而是略微扁平的,所以使用球形模型计算距离会引入一定的误差。为了准确计算距离,我们可以使用WGS84椭球恒向线距离。

恒向线距离是沿着地球表面上的某条弧线路径的实际距离。它与直线距离(即两点之间的直线距离)不同,因为地球的曲率和椭球形状会导致路径的弯曲。恒向线距离考虑了地球的曲率,并根据椭球形状进行了修正,因此可以更准确地计算两个地点之间的实际距离。

计算沿纬度和经度路径行驶的距离需要使用恒向线距离公式。该公式基于WGS84椭球体模型和经纬度坐标,通过考虑地球的曲率和椭球形状来计算两个地点之间的距离。公式的具体推导较为复杂,但可以通过使用数学软件或编程语言来实现。

在实际应用中,我们可以使用现有的地理信息系统软件或编程库来计算沿纬度和经度路径行驶的距离。这些软件和库通常已经实现了基于WGS84椭球恒向线距离的计算方法,并提供了简单易用的接口。通过输入起始和目标地点的经纬度坐标,我们可以获得沿路径行驶的实际距离。

总结起来,基于WGS84椭球恒向线距离的方法可以准确计算沿纬度和经度路径行驶的距离。通过考虑地球的曲率和椭球形状,我们可以避免使用简化的球形模型引入的误差。在现代导航和地理信息系统中,这种方法被广泛应用于计算两个地点之间的实际距离,为我们提供了准确的位置信息和导航指引。

🔥核心代码

%% pathdist 
% The |pathdist| function uses the |distance| function to calculate cumulative distance
% traveled along a path given by the arrays lat and lon.  (Requires Mapping
% Toolbox). Always assumes WGS84 ellipsoid. 
% 
%% Syntax
% 
%  pathDistance = pathdist(lat,lon)
%  pathDistance = pathdist(...,LengthUnit)
%  pathDistance = pathdist(...,track)
%  pathDistance = pathdist(...,'refpoint',[reflat reflon])
% 
%% Description
% 
% |pathDistance = pathdist(lat,lon)| returns the cumulative distance
% traveled along the path given by (|lat|,|lon|). Distance is in meters
% by default, referenced to the WGS84 ellipsoid. The |pathDistance| array
% will be the same size as |lat| and |lon|. 
%
% |pathDistance = pathdist(...,LengthUnit)| specifies any valid length unit. 
% The following are a few |LengthUnit| options. See documentation for 
% |validateLengthUnit| for a complete list of options.
% 
% * meter         |'m', 'meter(s)', 'metre(s)'| (default)
% * kilometer     |'km', 'kilometer(s)', 'kilometre(s)'|
% * nautical mile  |'nm', 'naut mi', 'nautical mile(s)'|
% * foot          |'ft', 'international ft','foot', 'international foot', 'feet', 'international feet'|
% * inch          |'in', 'inch', 'inches'|
% * yard          |'yd', 'yds', 'yard(s)'|
% * mile          |'mi', 'mile(s)','international mile(s)'|
%
% |pathDistance = pathdist(...,track)| uses the input string track to specify 
% either a great circle/geodesic or a rhumb line arc. If track equals |'gc'| (the default 
% value), then great circle distances are computed on a sphere and geodesic distances are 
% computed on the WGS84 ellipsoid. If track equals |'rh'|, then rhumb line distances are 
% computed on the WGS84 ellipsoid.
%
% |pathDistance = pathdist(...,'refpoint',[reflat reflon])| references the
% path distance to the point along the path nearest to |[reflat reflon]|.
% For this calculation, |pathdist| finds the point in |lat| and |lon|
% which is nearest to |[reflat reflon]| and assumes this point along
% |lat|,|lon| is the zero point. This is only an approximation, and may
% give erroneous results in cases of very sharply-curving, crossing, or 
% otherwise spaghetti-like paths; where |[reflat reflon]| lies far from any
% point along the path, or where points along the path are spaced far
% apart. 
% 
%% Example 1: Find distance traveled along a route marked by GPS measurements
% This example uses the built-in |sample_route.gpx| route. 
clc
clear all
close all
route = gpxread('sample_route.gpx'); % some sample data 
lat = route.Latitude; 
lon = route.Longitude; 
time = 0:255; % assume GPS measurements logged every minute

% Create a map of the route: 
figure('position',[100 50 560 800]) 
subplot(3,1,1) 
usamap([min(lat)-.05 max(lat)+.05],[min(lon)-.08 max(lon)+.08])
plotm(lat,lon,'ko-')
textm(lat(1),lon(1),'start','color',[.01 .7 .1]) 
textm(lat(end),lon(end),'end','color','r')


% Plot distance traveled:
metersTraveled = pathdist(lat,lon);

subplot(3,1,2) 
plot(time,metersTraveled)
box off; axis tight; 
xlabel('time (minutes)')
ylabel('meters traveled') 

% Plot speed: 
speed = diff(metersTraveled/1000)./diff(time/60); 

subplot(3,1,3) 
plot(time(2:end)-.5,speed)
box off; axis tight 
xlabel('time (minutes)') 
ylabel('speed (km/hr)')

%% Example 2: Calculate path length in miles referenced to a point
% Adding to the plot above, we will define a reference point at (42.354 N,
% 71.2 W). Then we will look at travel time as a function of distance from
% the reference point.  

reflat = 42.354; 
reflon = -71.2; 

subplot(3,1,1) 
plotm(reflat,reflon,'bp')
textm(reflat,reflon,'reference point','color','b') 

miFromRefPt = pathdist(lat,lon,'refpoint',[reflat reflon],'miles'); 

subplot(3,1,2) 
plot(miFromRefPt,time)
ylabel('travel time (min)') 
xlabel('distance from reference point (miles)') 
axis tight; box off; 

%% Author Info:

❤️

基于WGS84 椭球恒向线距离计算沿纬度_经度路径行驶的距离附matlab代码_无人机

⛄ 参考文献

[1] Jawak S , Luis A .Synergetic merging of Cartosat-1 and RAMP to generate improved digital elevation model of Schirmacher oasis, east Antarctica[J].Isprs International Archives of the Photogrammetry Remote Sensing & Spatial Information Sciences, 2014.DOI:10.5194/isprsarchives-XL-8-517-2014.

⛳️ 代码获取关注我

❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料

🍅 仿真咨询

1 各类智能优化算法改进及应用

生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化、公交排班优化、充电桩布局优化、车间布局优化、集装箱船配载优化、水泵组合优化、解医疗资源分配优化、设施布局优化、可视域基站和无人机选址优化

2 机器学习和深度学习方面

卷积神经网络(CNN)、LSTM、支持向量机(SVM)、最小二乘支持向量机(LSSVM)、极限学习机(ELM)、核极限学习机(KELM)、BP、RBF、宽度学习、DBN、RF、RBF、DELM、XGBOOST、TCN实现风电预测、光伏预测、电池寿命预测、辐射源识别、交通流预测、负荷预测、股价预测、PM2.5浓度预测、电池健康状态预测、水体光学参数反演、NLOS信号识别、地铁停车精准预测、变压器故障诊断

2.图像处理方面

图像识别、图像分割、图像检测、图像隐藏、图像配准、图像拼接、图像融合、图像增强、图像压缩感知

3 路径规划方面

旅行商问题(TSP)、车辆路径问题(VRP、MVRP、CVRP、VRPTW等)、无人机三维路径规划、无人机协同、无人机编队、机器人路径规划、栅格地图路径规划、多式联运运输问题、车辆协同无人机路径规划、天线线性阵列分布优化、车间布局优化

4 无人机应用方面

无人机路径规划、无人机控制、无人机编队、无人机协同、无人机任务分配
、无人机安全通信轨迹在线优化

5 无线传感器定位及布局方面

传感器部署优化、通信协议优化、路由优化、目标定位优化、Dv-Hop定位优化、Leach协议优化、WSN覆盖优化、组播优化、RSSI定位优化

6 信号处理方面

信号识别、信号加密、信号去噪、信号增强、雷达信号处理、信号水印嵌入提取、肌电信号、脑电信号、信号配时优化

7 电力系统方面

微电网优化、无功优化、配电网重构、储能配置

8 元胞自动机方面

交通流 人群疏散 病毒扩散 晶体生长 火灾扩散

9 雷达方面

卡尔曼滤波跟踪、航迹关联、航迹融合、状态估计