Light a Global Terrain Map

This example shows how to create a global topographic map and add a local light. The example also shows how to change the material and lighting properties and add a second light source.

Load the topo DTM files, and set up an orthographic projection.

load topo
axesm('mapprojection','ortho','origin',[10 -20 0])
axis off

Plot the topography and assign a topographic colormap.

meshm(topo,topolegend);
demcmap(topo)

Add a local light at a distance of 250 km above New York City, (40.75°N, 73.9°W). The first two arguments to lightm are the latitude and longitude of the light source. The third argument is its altitude, in units of Earth radii.

lightm(40.75,-73.9,500/earthRadius('km'),...
   'color','yellow','style','local')

Because the surface is quite dark, add more reflectivity by using the material function.

material([0.7270  1.0  1.0  4.0000  0.9925]) 
lighting Gouraud; hidem(gca)

Add more lights. This example adds a second light, colored magenta, and positioned over the Gulf of Arabia.

lightm(20,40,0.1,'color','magenta','style','local')