Mapping Toolbox | ![]() ![]() |
General Matrix Maps
In addition to regular matrix maps, the Mapping Toolbox provides another matrix map format: general matrix maps. These maps can be displayed, and their values and coordinates can be queried, but much of the functionality available for regular matrix maps cannot be exploited for general matrix maps.
The examples thus far have shown maps that covered simple, regular quadrangles, that is, geographically rectangular. General matrix maps, in addition to these rectangular orientations, can have other shapes as well.
The Map Format
To define a general matrix map, you need three variables: the matrix of indices or values associated with the mapped region, a matrix giving cell-by-cell latitude coordinates, and a matrix giving cell-by-cell longitude coordinates.
An example of an irregularly shaped general matrix map is available in the Mapping Toolbox for examination:
load mapmtx whos
Name |
Size |
Bytes |
Class |
|
|
|
|
lg1 |
50x50 |
20000 |
double array |
lg2 |
50x50 |
20000 |
double array |
lt1 |
50x50 |
20000 |
double array |
lt2 |
50x50 |
20000 |
double array |
map1 |
50x50 |
20000 |
double array |
map2 |
50x50 |
20000 |
double array |
Two general matrix maps are in this workspace, each requiring three variables. The values contained in map1
correspond to the latitude and longitude coordinates, respectively, in lt1
and lg1
. Notice that all three matrices are the same size. Similarly, map2
, lt2
, and lg2
together form a second general matrix map. These datasets were extracted from the topo
matrix map shown in previous examples. Neither of these maps is regular in that their columns do not run north-and-south.
To get an idea of their geography, display them together.
Notice that neither map is a regular rectangle. One looks like a diamond geographically, the other like a trapezoid. The trapezoid is displayed in two pieces because it crosses the edge of the map. These shapes can be thought of as the geographic organization of the data, just as rectangles are for regular matrix maps. But, just as for regular matrix maps, this organizational logic does not mean that displays of these maps are necessarily a specific shape.
Here you can view these maps together in a Polyconic projection.
Since the Polyconic is limited to a 150° range in longitude, those portions of the maps outside this region are trimmed automatically.
Geographic Interpretations
The Mapping Toolbox supports several different interpretations of general matrix maps. First, a map matrix having the same size as the latitude and longitude coordinate matrices represents the values of the map data at the corresponding geographic points. Next, a map matrix having one fewer row and column than the geographic coordinate matrices represents the values of the map data within the area formed by the four adjacent latitudes and longitudes. Finally, if the latitude and longitude matrices are still smaller than the map matrix, you can interpret them as describing a coarse graticule, or mesh of latitude and longitude cells into which the blocks of map data are warped.
This section discusses the first two interpretations of general matrix maps. For more information on the use of graticules, see The Graticule.
As an example of the first interpretation, consider a 4-by-4 map matrix whose cell size is 30-by-30 degrees, along with its corresponding 4-by-4 latitude and longitude matrices:
map = [ 1 2 3 4;... 5 6 7 8;... 9 10 11 12;... 3 14 15 16]; lat = [ 30 30 30 30;... 0 0 0 0;... -30 -30 -30 -30;... -60 -60 -60 -60]; long = [0 30 60 90;... 0 30 60 90;... 0 30 60 90;... 0 30 60 90];
This general matrix map is displayed with the values of map
shown at the associated latitudes and longitudes.
Notice that only 9 of the 16 total cells are displayed. The value displayed for each cell is the value at the upper left corner of that cell, whose coordinates are given by the corresponding lat
and long
elements. By MATLAB convention, the last row and column of the map matrix is not displayed, although they exist in the CData
property of the surface object.
For the second interpretation, consider a 3-by-3 map matrix with the same lat
and long
variables:
Here is a surface plot of the map matrix, with the values of map
shown at the center of the associated cells.
All of the map data is displayed for this general matrix map. The value of each cell is the value at the center of the cell, and the latitudes and longitudes in the coordinate matrices are the boundaries for the cells.
You may have noticed that the first row of the matrix is displayed as the top of the map, whereas for a regular matrix map, the opposite was true; the first row corresponded to the bottom of the map. This difference is due to the lat
and long
matrices and how they are ordered. The lat
and long
coordinate matrices determine the arrangement of the general matrix map.
Of course, a regular matrix map can also be considered a general matrix map. All that are required are the graticule or coordinate matrices, which can be produced from the regular matrix map itself using the meshgrat
function:
load topo [lat,lon] = meshgrat(topo,topolegend); whos
A regular matrix map can also be constructed from a general matrix map. The coordinates and values can be "imbedded" in a new regular matrix map with a somewhat coarser resolution. This ensures that every cell in the new map receives a value from the old one. Convert the diamond-shaped general matrix map back to a regular matrix map:
load mapmtx latlim = [min(lt1(:)) max(lt1(:))]; lonlim = [min(lg1(:)) max(lg1(:))]; [map,maplegend] = nanm(latlim,lonlim,1/2); % original was about 1 cell per degree map = imbedm(lt1,lg1,map1,map,maplegend);
![]() | Regular Matrix Maps | Displaying Maps | ![]() |