[GRASSLIST:5512] Re: A problem with computation in r.mapcalc
Glynn Clements
glynn.clements at virgin.net
Sat Feb 8 21:40:26 EST 2003
Miha STAUT wrote:
> I have a problem computing this with r.mapcalc:
>
> r.mapcalc < avg # piping
> avg=10*log((
> 10^(rast1/10-12)*6.863636
> +10^(rast2/10-12)*2.909091
> +10^(rast3/10-12)*3.742424
> +10^(rast4/10-12)*2.333333
> +10^(rast5/10-12)*2.318182
> +10^(rast6/10-12)*3.590909
> +10^(rast7/10-12)*0.969697
> +10^(rast8/10-12)*2.435484
> )
> *10^12/30.84457
> ,10)
>
> The process of computing seems to finish OK, but the new map gives only NAs.
> Why can that be? The problem appearently lies in the 10^rast. All the
> rasters have values between 0 and 140. The final map should not have
> excessively high values.
>
> How should I surround the problem?
First, I suggest converting all of the literals to floating-point,
e.g.
> *10.0^12.0/30.84457
An expression such as "10^12" will be computed using integer
arithmetic, which is likely to result in an overflow.
--
Glynn Clements <glynn.clements at virgin.net>
More information about the grass-user
mailing list