pathdist returns an array of the cumulative distance traveled along a path.
pathDistance = pathdist(lat,lon)
pathDistance = pathdist(...,LengthUnit)
pathDistance = pathdist(...,track)
pathDistance = pathdist(...,'refpoint',[reflat reflon])
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.
Chad Greene (2021). pathdist (https://www.mathworks.com/matlabcentral/fileexchange/47042-pathdist), MATLAB Central File Exchange. Retrieved .
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
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!