[GRASS-dev] Overflow warning in r.mapcalc calculation
Rainer M. Krug
Rainer at krugs.de
Wed May 15 06:51:21 PDT 2013
Paulo van Breugel <p.vanbreugel at gmail.com> writes:
> I am having trouble with the following computation, which gives me an overflow warning ("WARNING: Overflow occured in the
oerflow usually means that the result of a calculation does not fit into
the variable type selected, i.e. is either smaller then the smallest
value which can be stored or larger then the largest value.
GRASS uses FCELL (float) and DCELL (double) varisbles, where double can
store a larger range (sorry - I don't have the actual values at hand).
You should be able to do the calculations by explicitely converting the
result to double by using the double() function:
r.mapcalc "A = if(B==0, double( (round(C/0.0001)-1175699902)/(3007966667-1175699902) *100.0 ), 1) " --overwrite
should work, although untested.It is possible, thet the conversion to
double needs to be made inside the calculation, depending where the
actual overflow occurs.
> r.mapcalc "A = if(B==0, (round(C/0.0001)-1175699902)/(3007966667-1175699902) *100.0, 1)" --overwrite
> whereby C is a map with values between 1 and 31000. It seems to be related to the size of the numbers (no warning if I
> divide C by 0.001), but I am not clear what limit I am hitting here or how to avoid this.
> The warning does not stop the calculation, and the resulting map seems to be correct. However, I rather avoid this
> warning, also because the warning message causes problems when running in batch from within R.
Yes - overflow is a warning only, but *usually* results in wrong
results! I fell in that trap once and it took me some time to figure out
what was going on, as, if I remember correctly, no warning was issued
> I am running GRASS 7.0 on Ubuntu 13.04 64 bit.
> grass-dev mailing list
> grass-dev at lists.osgeo.org
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)
Centre of Excellence for Invasion Biology
Tel : +33 - (0)9 53 10 27 44
Cell: +33 - (0)6 85 62 59 98
Fax : +33 - (0)9 58 10 27 44
Fax (D): +49 - (0)3 21 21 25 22 44
email: Rainer at krugs.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 489 bytes
Desc: not available
More information about the grass-dev