[GRASS-user] Negative values for r.shaded.relief?

Glynn Clements glynn at gclements.plus.com
Tue Oct 23 08:38:34 PDT 2012


Patrick S. wrote:

> I am still trying to understand the output of shaded.relief to compare 
> to results of collegues created with other tools.
> When getting through the script I found the following calculation
> 
> /r.mapcalc << EOF//
> //$elev_out = eval( \\//

> // cang = sin($alt)*sin(slope) + cos($alt)*cos(slope) * cos($az-aspect), 
> \\//
> // if(cang < 0.,0.,100.*cang), \\//
> // if(isnull(cang), null(), 100.*cang))//
> //EOF/
> 
> How can it be that I have negative values in my output raster? Shouldn't 
> the line /if(cang < 0.,0.,100.*cang)/ prevent negative values and 
> multiply the result with 100?

No. That line does nothing.

eval() evaluates all arguments then returns the last argument. Prior
arguments are only meaningful if they have side effects, and the line
"if(cang < 0.,0.,100.*cang)" doesn't have any side effects.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list