comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » How to plot shaded relief image
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: How to plot shaded relief image [message #57995 is a reply to message #57830] Thu, 10 January 2008 03:56 Go to previous messageGo to previous message
JMB is currently offline  JMB
Messages: 13
Registered: January 2008
Junior Member
Very simple example in easy case:
South illumination, only sun angle (i) can be set:

;*********************************************************** *****
dem=read_tiff('dem.tif')
dims=size(dem,/dimensions)

; Edit a 3x3 gradient operator (vertical)

gradv=[[1,1,1],[0,0,0],[-1,-1,-1]]

; convolution of the dem with the 3x3 matrix

gradient=convol(float(dem),float(gradv))

; Sun angle respect to zenith (0 = vertical light, 90 = horizontal
light)

i=60
cosi=cos(i*!pi/180.)
sini=sin(i*!pi/180.)

; resx = Dem horizontal resolution in meter (needed for normalization)

resx=90 ; SRTM at 90 meter resolution in this test example
resxmat=make_array(dims[0],dims[1],value=2*resx) ; matrix used for the
scalar product

; Computation of the shading matrix:
; Scalar product of incident vector and normal gives cosinus angle

Norm=1/(sqrt(gradient^2+(2*resx)^2)) ; Normalization

costeta=Norm*(cosi*resxmat-sini*gradient)>0

window,0,xsize=dims[0],ysize=dims[1]
tvscl,dem
window,2,xsize=dims[0],ysize=dims[1]
tvscl,costeta

end
;*********************************************************** *****

Cheers,

Jérôme
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Problem Accessing Shared Objects
Next Topic: Window IDLDE 7.0 text copy idiosyncrasy

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 19:54:03 PDT 2025

Total time taken to generate the page: 1.75996 seconds