pathdist
pathdist returns an array of the cumulative distance traveled along a path.
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.
Cite As
Chad Greene (2024). pathdist (https://www.mathworks.com/matlabcentral/fileexchange/47042-pathdist), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- Simulink > Simulation >
- Mathematics and Optimization > Mapping Toolbox > Geometric Geodesy >
- Radar > Mapping Toolbox > Geometric Geodesy >
Tags
Acknowledgements
Inspired by: pos2dist, Vectorized geodetic distance and azimuth on the WGS84 earth ellipsoid, posdist, GREATCIRCLE and LOXODROME: "As the crow flies" and rhumb lin, gps_distance, LatLon distance, interpm2, disthist
Inspired: gdistm
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
pathdistdemo/html/
Version | Published | Release Notes | |
---|---|---|---|
1.4 | In this morning's release I accidentally set default units to kilometers. Default units are now meters. |
|
|
1.3.0.0 | Now includes support for miles, feet, nautical miles, and many more length units. |
|
|
1.2.0.0 | bug fix. |
||
1.1.0.0 | Now accepts NaN inputs. |
||
1.0.0.0 |