|On this page…|
Vector data (in the computer graphics sense rather than the physics sense) can represent a map. Such vectors take the form of sequences of latitude-longitude or projected coordinate pairs representing a point set, a linear map feature, or an areal map feature. For example, points delineating the boundary of the United States, the interstate highway system, the centers of major U.S. cities, or even all three sets taken together, can be used to make a map. In such representations, the geographic data is in vector format and displays of it are referred to as vector maps. Such data consists of lists of specific coordinate locations (which, if describing linear or areal features, are normally points of inflection where line direction changes), along with some indication of whether each is connected to the points adjacent to it in the list.
In the Mapping Toolbox™ environment, vector data consists of sequentially ordered pairs of geographic (latitude, longitude) or projected (x,y) coordinate pairs (also called tuples). Successive pairs are assumed to be connected in sequence; breaks in connectivity must be delineated by the creation of separate vector variables or by inserting separators (usually NaNs) into the sets at each breakpoint. For vector map data, the connectivity (topological structure) of the data is often only a concern during display, but it also affects the computation of statistics such as length and area.
load coast whos Name Size Bytes Class Attributes ans 1x45 90 char lat 9589x1 76712 double long 9589x1 76712 double
The variables lat and long are vectors in the coast MAT-file, which together form a vector map of the coastlines of the world.
axesm mercator framem plotm(lat,long)
Inspect the first 20 coordinates of the coastline vector data:
[lat(1:20) long(1:20)] ans = -83.83 -180 -84.33 -178 -84.5 -174 -84.67 -170 -84.92 -166 -85.42 -163 -85.42 -158 -85.58 -152 -85.33 -146 -84.83 -147 -84.5 -151 -84 -153.5 -83.5 -153 -83 -154 -82.5 -154 -82 -154 -81.5 -154.5 -81.17 -153 -81 -150 -80.92 -146.5
Does this give you any clue as to which continent's coastline these locations represent?
As you may have deduced by looking at the first column of the data, there is only one continent that lies below -80º latitude, Antarctica.
The above example presents the map in a Mercator projection. A map projection displays the surface of a sphere (or a spheroid) in a two-dimensional plane. As the word "plane" indicates, points on the sphere are geometrically projected to a plane surface. There are many possible ways to project a map, all of which introduce various types of distortions.
For further information on how Mapping Toolbox software manages map projections, see the Getting Started topic. For details on data structures that the toolbox uses to represent vector geodata, see Mapping Toolbox Geographic Data Structures.
You can also map data represented as a matrix (a 2-D MATLAB® array) in which each row-and-column element corresponds to a rectangular patch of a specific geographic area, with implied topological connectivity to adjacent patches. This is commonly referred to as raster data. Raster is actually a hardware term meaning a systematic scan of an image that encodes it into a regular grid of pixel values arrayed in rows and columns.
When data in raster format represents the surface of a planet, it is called a data grid, and the data is stored as an array or matrix. The toolbox leverages the power of MATLAB matrix manipulation in handling this type of map data. This documentation uses the terms raster data and data grid interchangeably to talk about geodata stored in two-dimensional array form.
A raster can encode either an average value across a cell or a value sampled (posted) at the center of that cell. While geolocated data grids explicitly indicate which type of values are present (see Geolocated Data Grids), external metadata/user knowledge is required to be able to specify whether a regular data grid encodes averages or samples of values.
When raster geodata consists of surface elevations, the map can also be referred to as a digital elevation model/matrix (DEM), and its display is a topographical map. The DEM is one of the most common forms of digital terrain model (DTM), which can also be represented as contour lines, triangulated elevation points, quadtrees, octtrees, or otherwise.
The topo global terrain data is an example of a DEM. In this 180-by-360 matrix, each row represents one degree of latitude, and each column represents one degree of longitude. Each element of this matrix is the average elevation, in meters, for the one-degree-by-one-degree region of the Earth to which its row and column correspond.
Raster geodata also encompasses georeferenced imagery. Like data grids, images are organized into rows and columns. There are subtle distinctions, however, which are important in certain contexts. One distinction is that an image may contain RGB or multispectral channels in a single array, so that it has a third (color or spectral) dimension. In this case a 3-D array is used rather than a 2-D (matrix) array. Another distinction is that while data grids are stored as class double in the toolbox, images may use a range of MATLAB storage classes, with the most common being uint8, uint16, double, and logical. Finally, for grayscale and RGB images of class double, the values of individual array elements are constrained to the interval [0 1].
In terms of georeferencing—converting between column/row subscripts and 2-D map or geographic coordinates—images and data grids behave the same way (which is why both are considered to be a form of raster geodata). However, when performing operations that process the values raster elements themselves, including most display functions, it is important to be aware of whether you are working with an image or a data grid, and for images, how spectral data is encoded.
For further details concerning the structure of raster map data, see Understanding Raster Geodata.
Load the topo data grid.
load topo topo
topoR = georasterref('RasterSize', size(topo), ... 'Latlim', [-90 90], 'Lonlim', [0 360]);
A figure window is created with map axes set to display a sinusoidal projection.
The geoshow function displays geodata in geographic (unprojected) coordinates. The geoshow output is shown below:
figure; axesm hammer meshlsrm(topo,topoR)
A colored relief map of the topo data set, illuminated from the east, is rendered in the second figure window.
For additional details on controlling the illumination of maps, see Shading and Lighting Terrain Maps.
Note that the content, symbolization, and the projection of the map are completely independent. The structure and content of the topo variable are the same no matter how you display it, although how it is projected and symbolized can affect its interpretation. The following example illustrates this.
Vector map variables and data grid variables are often used or displayed together. For example, continental coastlines in vector form might be displayed with a grid of temperature data to make the latter more useful. When several map variables are used together, regardless of type, they can be referred to as a single map. To do this, of course, the different data sets must use the same coordinate system (i.e., geographic coordinates on the same ellipsoid or an identical map projection). See the Getting Started topic for an introduction to Latitude, Longitude, Spherical Coordinates and other relevant topics.
Using the coast and topo data from the previous examples, you can combine them in a single map and see how well the two types of data work together:
topoR = georasterref('RasterSize', size(topo), ... 'Latlim', [-90 90], 'Lonlim', [0 360]); geoshow(topo,topoR,'DisplayType','texturemap') demcmap(topo)
Note that you can use geoshow to display both raster and vector data. Here is the resulting map.
For additional details on how Mapping Toolbox functions handles raster geodata, see Understanding Raster Geodata.
The remainder of this chapter focuses on the fundamental principles of geographic measurement and data manipulation that are a prerequisite for creating map displays. Reading and Writing Geospatial Data summarizes input functions for importing many formats of geospatial data into the toolbox. Getting Started introduces geodetic concepts that underlie all geospatial data and its handling.