Code covered by the BSD License  

Highlights from
DEM: Shaded relief image plot (digital elevation model)

4.875
4.9 | 8 ratings Rate this file 66 Downloads (last 30 days) File Size: 11.3 KB File ID: #36380
image thumbnail

DEM: Shaded relief image plot (digital elevation model)

by

François Beauducel

 

25 Apr 2012 (Updated )

Pretty shaded relief map as flat image.

| Watch this File

File Information
Description

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.

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.

Acknowledgements

This file inspired Shadem.

Required Products MATLAB
MATLAB release MATLAB 6.5 (R13)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (12)
24 Oct 2014 Matteo Niccoli

Matteo Niccoli

 
14 Aug 2014 amrit

amrit

 
13 Mar 2013 Fred Massin

Fred Massin

This is great to be able (finally!) to export vector shaded image with matlab, thank you!

11 Jan 2013 Mathieu

Mathieu

Exactly what I was looking for. Great Job!

08 Jan 2013 Julia

Julia

François,

Looking forward to using this code. For those of us who mask our DEMs with NaNs, it would be great to have an option to set NaN to white instead of black.

Thanks!

02 Dec 2012 François Beauducel

François Beauducel

Hi Carlo,
To add the colorbar you need to use the dem(...,'scale') option. Type doc dem to get all the available options.
François.

Comment only
01 Dec 2012 Carlo M

Carlo M

thank you for the code
please, how can I add a colorbar?

Comment only
10 Sep 2012 Zhishan

Zhishan

 
25 Jun 2012 sangram ganguly

sangram ganguly

This is a fantastic code - I love this as I do not have to use the surfl command and other mapping toolbox commands to generate my DEM and drape with other images. Thanks a ton !!
Guys - if you are dealing with 10m DEM with huge matrices, forget about mapping toolbox functions to do your draping - use this function - generate the DEM (use the matrices generated e.g. I in this case) and then use the geotiffwrite command to create beautiful tif images and do the rest in photoshop.

24 Jun 2012 François Beauducel

François Beauducel

Dear Cristopher,
You must download the file, unzip into your Matlab directory, then type "doc dem" at Matlab prompt.
Or, you can clic on dem.m (on the right of the function window under "Highlights from..."): this will display the function's comments including the doc.
François

Comment only
24 Jun 2012 cristopher

cristopher

Sorry, François:
I can't find the "doc dem" for sintax, examples and help.
Can you help me

Comment only
28 May 2012 Martin Richard

Martin Richard

 
Updates
26 Apr 2012

Optimizations: adds a decimation for large DEM grids.

14 May 2012

ZIP now contains landcolor.dat companion file.

18 May 2012

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

29 May 2012

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

26 Sep 2012

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

02 Jan 2013

- adds a 'lake' option
- minor bug correction

07 Jan 2013

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

14 Jan 2013

- 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

11 Mar 2013

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

09 Sep 2014

improve backward compatibility (strjoijn)

Contact us