[Gdal-dev] RE: shaded relief utility (DIY)

Charles Wivell Charles.Wivell at dnr.state.mn.us
Mon Nov 6 09:21:37 EST 2006

Hi George;

The equation you have is the gradient of z in either the x or y
direction (the matrix can also be used to calculate an edge image (Sobal
edge image)).

The equation will give you elevation between postings. However, to
create a shaded relief, you need to calculate the illumination angles.
To do that you first need to find the normal vector to the elevation
surface = tangent at a point. You then need to create a vector from your
point to your light source (the Sun?). The angle between these two
vectors is the zenith angle. A brightness value can then be calculated
using B = Acos(zenith_angle). Where A is just a scalar to get your
brightness in the range you want.

You could use the gradient equation to find the tangent vector in the x
direction and the tangent vector in the y direction and then cross the
two vectors to get the normal vector at that point.

Usually a shaded relief is just a qualitative thing, so a good
approximation is just to create two vectors between one positing (the
posting of interest) and the next posting in the x direction and the
next posting in the y direction. If you then cross these two vectors,
you get the approximate normal at the posting of interest.


Charles Wivell
MN DNR Forestry/Resource Assessment
413 SE 13th Street
Grand Rapids, MN 55744
218-327-4449 x 233

>>> odhiambo george <odhiambogeorge at yahoo.com> 11/1/2006 5:38 AM >>>
Dear Sir,
  I'm trying to write a MATLAB program for calculating or creating
shaded relief from a DEM. I have come across the equation attached to
this e-mail which i believe represents calculation of the cell values
  What I don't undersyand is how to handle the DEM, for example, how do
I use the DEM together with the equation  ?
  Kindly assist by shedding some light on the procedure used
  Kind regards,

Access over 1 million songs - Yahoo! Music Unlimited Try it today.

More information about the Gdal-dev mailing list