Main Content

Add Light Source to Terrain Map

Add a light source to a terrain map for a region around South Boulder Peak in Colorado.

First, import elevation data and a geographic postings reference object. To plot the data using geoshow, the raster data must be of type double or single. Therefore, specify the data type for the raster using the 'OutputType' name-value pair.

[Z,R] = readgeoraster('n39_w106_3arc_v2.dt1','OutputType','double');

Then, display the data as a surface. Apply a colormap appropriate for terrain data using the demcmap function.


Set the vertical exaggeration using the daspectm function. Then, specify a light source in the top left corner of the map. Find the coordinates of the top left corner by querying the LatitudeLimits and LongitudeLimits properties of the reference object.

cornerlat = R.LatitudeLimits(2);
cornerlon = R.LongitudeLimits(1);

Restore the luminance of the map by specifying the ambient, diffuse, and specular light strength.

ambient = 0.7; 
diffuse = 1;
specular = 0.6;
material([ambient diffuse specular])

The DTED file used in this example is courtesy of the US Geological Survey.

See Also


Related Topics