✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,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.clcclear allclose allroute = gpxread('sample_route.gpx'); % some sample datalat = 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 tightxlabel('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:
❤️ 运行结果

⛄ 参考文献
[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.
本文介绍了如何在现代导航和GIS中使用WGS84椭球恒向线距离计算沿纬度和经度路径的实际距离,以减少因地球曲率产生的误差,特别提到了Matlab中的相关函数实现和应用实例。
1446

被折叠的 条评论
为什么被折叠?



