Traveling somewhere soon? Visualize your flight plan on a 3d globe with the Matlab Mapping Toolbox and Plotly!
If you haven’t used Plotly with Matlab before it’s easy to get started by following these simple instructions. Additionally, latitude & longitude flight plan data can be found online on sites such as Flight Plan Database.
With the Matlab Mapping Toolbox, construct a basic globe display.
grs80 = referenceEllipsoid('grs80','km');
figure('Renderer','opengl')
ax = axesm('globe','Geoid',grs80,'Grid','on','GLineWidth',1, ...
'GLineStyle','-', 'Gcolor',[0.9 0.9 0.1],'Galtitude',100);
axis equal off
view(3)
Next, add low-resolution global topography, coastlines, and rivers to the globe.
load topo
geoshow(topo,topolegend,'DisplayType','texturemap')
demcmap(topo)
land = shaperead('landareas','UseGeoCoords',true);
plotm([land.Lat],[land.Lon],'Color','black')
rivers = shaperead('worldrivers','UseGeoCoords',true);
plotm([rivers.Lat],[rivers.Lon],'Color','blue')
To add a flight plan, create arrays of the latitude and longitude data for the flight, then plot the latitude by longitude.
flight.Lat = [ADD LATITUDES];
flight.Lon = [ADD LONGITUDES];
plotm([flight.Lat],[flight.Lon],'Color','red')
Parse the figure with the following statement:
pf = fig2plotly(gcf,'open',false,'strip',false, 'filename', ...
'ADD_YOUR_FILENAME', 'fileopt','overwrite');
Adjust the trace style (color and line width) on the Plotly figure for {1} Latitude, {2} Longitude, {3} Surface Water, {4} Land Lines, {5} Rivers, and {6} Flight Plan
For lines (in this example: everything except Surface Water):
pf.data{1}.line.color = 'rgb(80, 20, 80)';
pf.data{1}.line.width = 0.75;
pf.data{1}.name = 'Latitude';
For surfaces (in this example: Surface Water):
pf.data{3}.colorscale = {{0,'rgb(31, 119, 180)'}, {1, 'rgb(0, 0, 0)'}};
pf.data{3}.opacity = 0.4;
Adjust the layout and axes.
pf.layout.scene.bgcolor = 'rgb(0, 0, 0)';
pf.layout.showlegend = true;
In the graph below, the axes grids are hidden. Repeat the code below for the y and z axes to hide all grid information in the plot.
pf.layout.scene.xaxis.showgrid = false;
pf.layout.scene.xaxis.zeroline = false;
pf.layout.scene.xaxis.showspikes = false;
pf.layout.scene.xaxis.showticklabels = false;
Finally, graph the figure online with Plotly!
pf.plotly;
You can find the full matlab script and data used to make the flight plans for the figure below here!
Creating dashboards or visualizations at your company? Consider Plotly Enterprise for modern intracompany graph and data sharing.