How do I plot a line between two points lying on the same longitude (or latitude) such that the line passes through all the intermediate points on the same longitude in Mapping Toolbox 3.3 (R2011a)

2 views (last 30 days)
I am using the Mapping Toolbox 3.3 (R2011a). I have a set of 3 points all lying on the same longitude but different latitudes. When I draw a line between the two end points using the LINEM function, I observe that the line does not pass through the intermediate point in some instances. How do I plot a line between two points on the same longitude, such that it passes through the intermediate point?
Similarly how do I plot a line which passes through points on the same latitude but different longitudes?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 29 Oct 2012
The issue is caused due to the way the LINEM function in Mapping Toolbox 3.3 (R2011a) plots a line. The LINEM function projects the two end points to the axes in the figure and then draws a straight line between the two end points.
The intermediate points on the line however, are not projected onto the axes, which is why a line connecting two points on the same longitude will not necessarily be drawn along a constant longitude value.
To work around this issue, the lines connecting the two points should be along a great circle or a rhumb line. Great Circles connect points on the same longitude, rhumb lines connect points on the same latitude. To create those lines refer to example number 4 in the demo given in the link:
<http://www.mathworks.com/help/releases/R2012b/map/displaying-vector-data-with-mapping-toolbox-functions.html>
In the documentation, the great circle track or a rhumb line track between two points is computed using the TRACK2 function and plotted using the PLOTM function.
More information about the TRACK2 function is available on the following link.
<http://www.mathworks.com/help/releases/R2012b/map/ref/track2.html>
The PLOTM function is a higher level function compared to LINEM and projects a line onto the map axes.
More information on the PLOTM function can be found at the following documentation link:
<http://www.mathworks.com/help/releases/R2012b/map/ref/plotm.html>
Plotting great circle tracks (and rhumb line tracks) will ensure that the track connecting the two points on the same longitude (or two points on the same latitude) will pass through all the intermediate points also lying on the same longitude (or latitude).
Tracks generated between the two end points are along the shortest path between the two end points.

More Answers (0)

Products


Release

R2011a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!