DEM: Shaded relief image plot (digital elevation model)

Pretty shaded relief map as flat image.
Updated 20 May 2019

View License

This function plots regular grids of elevation X,Y,Z in a more efficient manner than SURFL Matlab's function, because it recomputes lighting and displays result as shaded color flat RGB image. It uses also median-style filter to deal with min/max values of elevations and gradient, and proposes two specific colormaps "landcolor" and "seacolor".
Color mapping and lighting parameters can be changed from default values. In addition, several options are available: 'cartesian' to add decimal axis, 'latlon' to add geographical axis (GMT-like), 'legend' for an automatic scaling legend, 'lake' for automatic flat area color-filling and 'interp' to fill the novalue gaps...
This may be useful to produce high-quality and moderate-size Postscript image adapted for publication. Also, the output image is not dependant on current figure colormap, thus additional plots with indexed colors can be added (contour, pcolor, ...).
Figure examples:
Moon North Pole using the bone colormap and high contrast lighting (DEM source: raster LRO/LOLA LTVT)
Indonesia archipelago using default colormaps, 'latlon' axis basemap and legend scales (DEM source: raster NOAA/NGDC ETOPO1)

Soufrière of Guadeloupe volcano lava dome: 1-m resolution with NaN values (DEM source: OVSG-IPGP/SCIAC)

See "doc dem" for syntax, examples and help. See also the READHGT function from same author.

Cite As

François Beauducel (2024). DEM: Shaded relief image plot (digital elevation model) (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: shadem

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

- improves the colormap splitting between land and sea
- new option 'lakezmin' to limit lake detection

- new option 'position' for tick labels
- major update thanks to mas Wiwit

minor fix

legend scale is now liberated from the figure colormap (thanks to Tomke Froechtenich's comment). No use of freezecolors needed to add other colormap plots.

improve backward compatibility (strjoijn)

- new options: 'km', 'watermark', 'fontsize', 'bordersize'
- improve legend colorbar
- all options now passed as param/value

- improved light rendering (using surface normals instead of gradient)
- improved 'lake' detection algorithm
- new 'nancolor' option to set NaN color
- adds a length scale with 'dec' option
- minor code improvements

- adds 'interp' option (fill the gaps)
- adds 'seacolor' colormap for negative elevations (bathymetry)

- adds a 'lake' option
- minor bug correction

now accepts row/column vectors for X and/or Y.

- adds basemap-style axis in decimal or lat/lon modes
- adds elevation and distance scales

- new landcolor.m colormap function
- new arguments to control colormap scaling
- median-style filters for light and colormap

ZIP now contains landcolor.dat companion file.

Optimizations: adds a decimation for large DEM grids.