This example shows how to create 3-D displays with raster data by setting up surface views, which requires explicit horizontal coordinates. The simplest way to display raster data is to assign colors to matrix elements according to their data values and view them in two dimensions. Raster data maps also can be displayed as 3-D surfaces using the matrix values as the z data. The difference between regular raster data and a geolocated data grid is that each grid intersection for a geolocated grid is explicitly defined with x-y or latitude/longitude matrices or is interpolated from a graticule, while a regular matrix only implies these locations (which is why it needs a reference vector, matrix, or object).
Load elevation data and a geographic cells reference object for the Korean peninsula. Transform the data and reference object to a fully geolocated data grid using the meshgrat
function.
load korea5c
[lat,lon] = meshgrat(korea5c,korea5cR);
Next use the km2deg
function to convert the units of elevation from meters to degrees, so they are commensurate with the latitude and longitude coordinate matrices.
korea5c = km2deg(korea5c/1000);
Observe the results by typing the whos
command. The lat
and lon
coordinate matrices form a mesh the same size as korea5c
. This is a requirement for constructing 3-D surfaces. In lon
, all columns contain the same number for a given row, and in lat
, all rows contain the same number for a given column. This is because the mesh
produced by meshgrat
in this case is regular, but such data grids need not have equal spacing.
whos
Name Size Bytes Class Attributes description 2x64 256 char korea5c 180x240 345600 double korea5cR 1x1 128 map.rasterref.GeographicCellsReference lat 180x240 345600 double lon 180x240 345600 double source 2x76 304 char
Now set up a map axes object with the equal area conic projection and, instead of using the meshm
function to make this map, display the geolocated data grid using the surfm
function. Set an appropriate colormap. This produces a map that is really a 3-D view seen from directly overhead (the default perspective). To appreciate that, all you need to do is to change your viewpoint.
axesm('MapProjection','eqaconic','MapParallels',[],... 'MapLatLimit',[30 45],'MapLonLimit',[115 135]) surfm(lat,lon,korea5c,korea5c) demcmap(korea5c) tightmap
Specify a viewing azimuth of 60 degrees (from the east southeast) and a viewing elevation of 30 degrees above the horizon, using the view
function.
view(60,30)