This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Surface Relief Shading

You can make dimensional monochrome shaded-relief maps with the function surflm, which is analogous to the MATLAB® surfl function. The effect of surflm is similar to using lights, but the function models illumination itself (with one “light source” that you specify when you invoke it, but cannot reposition) by weighting surface normals rather than using light objects.

Shaded relief maps of this type are usually portrayed two-dimensionally rather than as perspective displays. The surflm function works with any projection except globe.

The surflm function accepts geolocated data grids only. Recall, however, that regular data grids are a subset of geolocated data grids, to which they can be converted using meshgrat (see Fit Gridded Data to the Graticule). The following example illustrates this procedure.

Create Monochrome Shaded Relief Map

This example shows how to use surflm to simulate a single light source in a figure. The example uses worldmap to set up an appropriate map axes and reference outlines.

Set up a projection and display a vector map of the Korean peninsula with worldmap. worldmap chooses a projection and map bounds to make this map.

figure;
ax = worldmap('Korea, Republic of');

latlim = getm(ax,'MapLatLimit');
lonlim = getm(ax,'MapLonLimit');

coastline = shaperead('landareas',...
    'UseGeoCoords', true,...
    'BoundingBox', [lonlim' latlim']);

geoshow(ax, coastline, 'FaceColor', 'none');

Load the korea terrain model.

load korea

Generate the grid of latitudes and longitudes to transform the regular data grid to a geolocated one.

[klat,klon] = meshgrat(map,refvec);

Use surflm to generate a default shaded relief map, and change the colormap to a monochromatic scale, such as gray, bone, or copper. In this default case, the lighting direction is set at 45º counterclockwise from the viewing direction; thus the "sun" is in the southeast.

ht = surflm(klat,klon,map);
colormap('copper')

To make the light come from some other direction, specify the light source's azimuth and elevation as the fourth argument to surflm. Clear the terrain map and redraw it, specifying an azimuth of 135º (northeast) and an elevation of 60º above the horizon.

clmo(ht);
ht=surflm(klat,klon,map,[135,60]);

The surface lightens and has a new character because it is lit closer to overhead and from a different direction.

Now shift the light to the northwest (-135º azimuth), and lower it to 40º above the horizon. Because a lower "sun" decreases the overall reflectance when viewed from straight above, also specify a more reflective surface as a fifth argument to surflm. This is a 1-by-4 vector describing relative contributions of ambient light, diffuse reflection, specular reflection, and a specular shine coefficient. It defaults to [.55 .6 .4 10].

clmo(ht);
ht=surflm(klat,klon,map,[-135, 30],[.65 .4 .3 10]);

This is a good choice for lighting this terrain, because of the predominance of mountain ridges that run from northeast to southwest, more or less perpendicular to the direction of illumination.

Shaded relief representations can highlight the fine structure of the land and sea floor, but because of the monochromatic coloration, it is difficult to distinguish land from sea. See Colored Surface Shaded Relief to learn how to color such maps to differentiate land from water.