Newsletters - MATLAB Digest
Maps Made Easy
by Walter Stumpf
Send email to Walter Stumpf c/o Russ Minkwitz
MATLAB's extensive collection of numerical methods and programming capabilities have led to applications that range from aerospace engineering to zoology. Many of these applications produce data that have a geographic context. The Mapping Toolbox makes it easy to create maps to display and analyze your data. This article will show you some new functions that make creating these maps even easier.
Before widespread use of computers, we probably would have taken a paper map and hand drawn the data on top. Copies of this base map might have been on hand, and each new data set would have been redrawn. We would have given little thought to the base map, though it would have been smart to work with a cartographer to ensure the map's suitability.Notice how the appearance of the map changed as we asked for a smaller region. Worldmap picked a different projection, switched to higher resolution atlas data, and added cities and country labels as the risk of clutter was reduced.
We can also override some of the default choices. For example, we can specifiy all of the high-resolution atlas data, even the smallest islands, for countries with names beginning with "Korea", are displayed as lines only.
close all
worldmap('allhi','korea','lineonly')
Now we can easily add our earthquake data to this base map. The Mapping Toolbox always adds displayed data to an existing map, rather than replacing it as MATLAB does. Mapping Toolbox display commands are just like those in MATLAB, except that they use geographic spherical coordinates instead of Cartesian. Here we load our earthquake data and display it on the base map as markers with the area proportional to the square of the magnitude. We also change the marker face color to white to clarify close events, and move the markers to below the atlas data.
load koreaEQdata
whos
Name |
Size |
Bytes |
Class |
CAPTION |
4x68 |
544 |
char array |
kdata |
803x3 |
19272 |
double array |
Grand total is 2681 elements using 19816 bytes
![]()
h = scatterm(kdata(:,1),kdata(:,2),kdata(:,3).^2,'r','filled');
set(h,'markerfacecolor','w')
zdatam(h,-10)
![]() |
| Click to see enlarged view (30 k) |
Another way to specify the region is by latitude and longitude limits. If you don't know the limits of a small region in advance, it's convenient to make a larger map, and then define the limits by clicking on the map. For example, to make a base map of the southern Japanese island of Kyushu, you can use the map of the Korean Peninsula and then use inputm to define the limits: ![]()
[latlim,lonlim]=inputm(2)
latlim =
34.4886
30.7035
lonlim =
129.0171
133.5265
figure
worldmap(latlim,lonlim,'lineonly')
h = scatterm(kdata(:,1),kdata(:,2),kdata(:,3).^2,'r','filled');
set(h,'markerfacecolor','w')
zdatam(h,-10)
If these functions do not produce the base map you want, you can use the lower level map projection and atlas commands to retain complete control over the base map.
axesm('mapprojection','ortho','origin',[40 120],...
'mlinelocation',15,'plinelocation',15,...
'mlinelimit',[-75 75],'mlineexception',-180:90:90,...
'grid','on','frame','on')
displaym(worldlo('POpatch'))
polcmap
hidem(gca)
set(gcf,'color','w')
tightmap loose
Store







