
How to plot multiple lines over a geographic area using the 'geoplot3' and 'geoglobe' functions?
    27 views (last 30 days)
  
       Show older comments
    
    MathWorks Support Team
    
 on 29 Apr 2020
  
    
    
    
    
    Edited: MathWorks Support Team
    
 on 22 Dec 2022
            How to plot multiple 3d plots using the 'geoplot3' and 'geoglobe' functions?
Accepted Answer
  MathWorks Support Team
    
 on 18 Oct 2022
        
      Edited: MathWorks Support Team
    
 on 22 Dec 2022
  
      There are two things to keep in mind while using the 'geoglobe' function to plot multiple plots: 
1. Firstly, the 'geoglobe' function has a default property of deleting existing plots and reset globe properties, except 'Position' and 'Units', to their default values before displaying the new plot. In order to allow multiple plots to be plotted on the globe the user needs to specify the 'NextPlot' name-value pair argument as 'add' as shown below in the example:
uif = uifigure;
g = geoglobe(uif,'NextPlot','add');
Additionally, please refer to the following documentation regarding the NextPlot property:
https://www.mathworks.com/help/map/ref/globe.graphics.geographicglobe.html#mw_6c760b8f-7d02-4f56-95f1-85a0ec557e20
2. Secondly, only certain 'hold' syntaxes are supported by the 'geoglobe' function as shown below:
hold(g) %toggles the state between off and on
hold(g,'on') % retains plot so that new plots can be added to the same plot
hold(g,'off') % releases the current plot
Please refer to this documentation link which describes the supported 'hold' syntax:
https://www.mathworks.com/help/map/ref/globe.graphics.geographicglobe.html#mw_6ed71245-e876-4a96-9bb1-eb2162df345d
Additionally, please refer to this sample MATLAB code that will demonstrate how to plot multiple line plots over a local region using the 'geoplot3' function:
trk = gpxread('sample_mixed','FeatureType','track');
lat = trk.Latitude;
lon = trk.Longitude;
h = trk.Elevation;
lat1 = 0.98*(trk.Latitude);
lon1 = 0.98*(trk.Longitude);
h1 = 0.98*(trk.Elevation);
uif = uifigure;
g = geoglobe(uif,'NextPlot','add');
geoplot3(g,lat,lon,h,'c')
hold(g,'on')
mskip = 1:25:length(lat1);
geoplot3(g,lat1,lon1,h1,'ro','MarkerIndices',mskip)
Resulting figure:

0 Comments
More Answers (0)
See Also
Categories
				Find more on Geographic Plots in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!