MATLAB: How to plot on a line on the surface of the earth

geoshowglobeplot3mplotm

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!

Best Answer

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');