How can I plot on a line on the surface of the earth?

19 views (last 30 days)
Hi, I am having trouble plotting a line on the surface of the earth. I would ideally like to input two lat, long points and get a great-circle route(the shortest route) line in between them plotted on the surface of the globe.
I have been using Matlab's globe feature, however, I have not gotten this to work. I have been trying to follow a similar format to: http://www.mathworks.com/help/map/examples/plotting-a-3-d-dome-as-a-mesh-over-a-globe.html but I can't get it to work.
Thanks for your help!

Accepted Answer

Kelly Kearney
Kelly Kearney on 22 Mar 2013
Edited: Kelly Kearney on 22 Mar 2013
The example you point to may be a little more complicated than you need for your purposes, though you should be able to follow steps 4 and 5 pretty closely. The example below skips adding all the topographic details, and just plots simple coastlines with a solid-colored base.
The track command calculates the proper path connecting the points, since connecting two distant points on the globe "projection" will go straight through the geoid rather than following the surface.
% Two points, [lat lon]
pt = [...
47.4 -122.6
28.5 -83.173];
% Calculate great circle path
ltln = [42.2 26.8; -12107 -80.9];
[lttrk, lntrk] = track('gc', pt(:,1), pt(:,2));
% Create globe
figure;
axesm ('globe','Grid', 'on');
axis off;
view(3);
% Add an opaque surface
base = zeros(180,360); baseref = [1 90 0];
% hs = meshm(base,baseref,size(base));
colormap white;
% Plot coastlines and your selected arc
load coast;
plotm(lat, long);
plotm(lttrk, lntrk, 'r');

More Answers (1)

Reeve
Reeve on 22 Mar 2013
Ah thank you so much, this is exactly what I was looking for!

Community Treasure Hunt

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

Start Hunting!