12

Blog | Mapping Toolbox in MATLAB | LMS Portal | MATLAB Helper ®

 3 years ago
source link: https://matlabhelper.com/blog/matlab/mapping-toolbox-in-matlab/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

What does a Mapping toolbox do?

Imagine that you are given the task of displaying the population of countries. Wouldn’t it be more attractive when this data is displayed in a map, rather than a table? This is precisely what the mapping toolbox helps us with. Before seeing about how to create maps and globes, let us see what a Mapping toolbox does and what its uses are. Mapping Toolbox provides algorithms, functions, and app for analysing geographic data and creating map displays in MATLAB. You can import vector and raster data from a wide range of file formats and web map servers. Geospatial data can be combined with base map layers from multiple sources in a single map display.

Primary functions of the toolbox

In this blog, we shall see a few essential functions of this toolbox. The main topic that we will be concentrating in this blog would be performing various 2D and 3D maps and globe displays. We are going to see the following implementations in MATLAB:

  1. Creating Maps Using MAPSHOW
  2. Display a Rotating Globe
  3. Creating an Interactive globe
  4. Visualizing the COVID-19 cases in a map

1) Creating Maps Using MAPSHOW

As a beginner and very first step, we shall see how we can create different varieties of road maps using the mapshow function in a simple code. As the first step in every code, we would use the clc, clear, and close commands to clear all the variables and close all the opened images.

clc
clear
close all

Map 1: Roads - A Geographic Data Structure

Map 2: Roads with Custom LineStyle

Map 3: Roads with SymbolSpec

Map 4: GeoTIFF Image of Boston

2) Display a Rotating Globe

As a second application of the mapping toolbox, we shall see how to animate to produce a rotating globe.

clc
clear
close all

Now we shall set up a Globe display. The view is from above the North Pole.

figure
axesm('globe');
gridm('GLineStyle','-','Gcolor',[.7 .8 .9],'Grid','on')

In the above figure, the globe appears similar to how it will look when we see it from above the north pole. It looks like a 2-D circle, rather than a 3-D sphere.

Next, we shall spin the globe by one revolution.

set(gca,'Box','off','Projection','perspective')
spin

For this, we have used the spin.m function in MATLAB.

% spin.m: Rotates a view around the equator one revolution
% in 5-degree steps. Negative step makes it rotate normally
% (west-to-east).
for i=90:-5:-270
    view(i,23.5); % Earth's axis tilts by 23.5 degrees
    drawnow
end

We have the skeletal structure of the 3-D globe in the above image.Add the base color of copper color to give a feeling of land and spin at a slower rate.

base = zeros(180,360);
baseR = georefcells([-90 90],[0 360],size(base));
copperColor = [0.62 0.38 0.24];
hs = geoshow(base,baseR,'FaceColor',copperColor);
setm(gca,'Galtitude',0.025);
axis vis3d
spin

Show the Earth in space. Blacken the figure background, turn off the three axes, and spin again.

clmo(hs)

load topo
topo = topo / (earthRadius('km')* 20);
hs = meshm(topo,topolegend,size(topo),topo);
demcmap(topo)

set(gcf,'color','black');
axis off;
spin

The above figure shows the globe with its geographic colors of green and blue.

Applying lighting, which shifts as the planet rotates and makes it brighter.

camlight right
lighting Gouraud;
material ([.7, .9, .8])

The above picture shows a brighter globe and also with more clear terrains.

MH Quiz Contest - Dec'20

Online MCQ Quiz on Machine Learning & MATLAB

Special Prize applicable till 31st December 2020. Hurry up!

3) Creating an Interactive globe

In the third application topic, we will see how we can construct a map of major world cities enhanced with coastlines and terrain. We shall also see how to interactively pick a location and get the name and location of the nearest city.

clc
clear
close all

Set up a Map Axes Object and Render a Global Elevation Grid. Construct the axes.

figure
axesm bries
text(.8, -1.8, 'Briesemeister projection')
framem('FLineWidth',1)

Load and display a 1-by-1-degree elevation grid.

load topo
geoshow(topo, topolegend, 'DisplayType', 'texturemap')
%Improve the Terrain Display. Get a colormap appropriate for elevation.
demcmap(topo)
%Make it brighter
brighten(.5)
%Add Simplified Coastlines. Load global coastline coordinates
load coastlines
%Generalize the coastlines to 0.25-degree tolerance
[rlat, rlon] = reducem(coastlat,coastlon, 0.25);
%Plot the coastlines in brown.
geoshow(rlat, rlon, 'Color', [.6 .5 .2], 'LineWidth', 1.5)

Plot City Locations with Red Point Markers

Select Cities Interactively

As the output of this code, we can see how the map will be projected in a Briesemeister projection. Also, here I have placed the cursor near Delhi, and we can see the output name mentioned as New Delhi along with its latitude and longitude coordinates displayed as 28.63 and 77.21.

4) Visualizing the COVID-19 cases in a map

The entire world is now in a hazardous situation as we see the number of COVID-19 cases rising in huge numbers daily. As a final application of this blog, I felt it would be relevant if we can plot and visualize the Covid-19 cases in a map using the mapping toolbox.

Geobubble mapping

Geobubble mapping format will be used for the visualizing purpose, where the cases will be shown in the form of a bubble in each country. The size and color of the bubble would indicate the severity of the disease. Highly affected countries would have a more giant bubble in the map compared to a country with a low number of cases. This is the geobubble mapping format.

clc
clear
close all

Getting data of the countries

Visualization of Geo Bubble mapping

Conclusion

In this blog, we came across a few essential functions and implementations of the mapping toolbox. We also saw one application of it relevant to today’s situation. The mapping toolbox can also be extended to various other applications such as Web mapping, Terrain and elevation analysis, Geometric Geodesy and map projections, Data representation and transformations, etc.

Loved the Blog? Gives us your valuable feedback through comments!

Thank you for reading this blog. Do share this blog, if you found it helpful. If you have any query, post it in the comments or get in touch with us by emailing your questions to [email protected]. Follow us on LinkedInFacebook and Subscribe to our YouTube Channel. We have expanded the traditional classroom teaching to meet the needs of today's learners. Our experts assist in all MATLAB & Simulink fields with communication options from live sessions to offline work with Pricing suitable for everyone. You can get offline help via email or opt for online zoom meetings with one-click content sharing, real-time co-annotation, and digital whiteboard.

If you are looking for one-time expert help, you can go ahead with Pay As You Go Plan. If your task is research-oriented like thesis support or paper implementation and you have a proper timeline, our recommendation would be Research Assistance, a monthly plan with a steady reduction of 10% of the expert fee up to six months of subscription. We also offer Corporate Assistance for requirements with annual validity. The minimum expert booking time is 1 hour under the Pay As You Go plan. You can book 5/10/20 hours under the Research Assistance plan. You will get expert help for the time you book only after you have an active order.

If you are looking for an expert's help and ready for the paid service, share your requirement with necessary attachments & inform us about any Service preference along with the timeline. Once evaluated, we will revert back to you with more details and the next suggested step.

Education is our future. MATLAB is our feature. Happy MATLABing!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK