<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000099">
Hi Rainer,<br>
<br>
Thanks a lot for your reply. The problem is indeed that the result
of the calculation does not fit into the variable and your answer
made me realize I had to take a closer look at what happens inside
the formula. As it turns out, the problem lies in the following part
of the formula:<br>
<pre wrap="">round(C/0.0001)</pre>
The output of round() is an integer and c/0.0001 gives values that
are larger then the maximum number for integer layers (which I
presume is (2^31)-1). So I need to rethink the formula and the use
of round.<br>
<br>
Paulo<br>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 05/15/2013 03:51 PM, Rainer M. Krug
wrote:<br>
</div>
<blockquote cite="mid:8738touzae.fsf@krugs.de" type="cite">
<pre wrap="">
Paulo van Breugel <a class="moz-txt-link-rfc2396E" href="mailto:p.vanbreugel@gmail.com"><p.vanbreugel@gmail.com></a> writes:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,
I am having trouble with the following computation, which gives me an overflow warning ("WARNING: Overflow occured in the
calculation").
</pre>
</blockquote>
<pre wrap="">
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:
UNTESTED:
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.
</pre>
<blockquote type="cite">
<pre wrap="">
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.
</pre>
</blockquote>
<pre wrap="">
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
(GRASS 6.4?).
Cheers,
Rainer
</pre>
<blockquote type="cite">
<pre wrap="">
I am running GRASS 7.0 on Ubuntu 13.04 64 bit.
Best
Paulo
_______________________________________________
grass-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:grass-dev@lists.osgeo.org">grass-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/grass-dev">http://lists.osgeo.org/mailman/listinfo/grass-dev</a>
</pre>
</blockquote>
<pre wrap="">
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Paulo van Breugel
Department of Geosciences and Natural Resource Management
Section of Forest, Nature and Biomass
University of Copenhagen
Rolighedsvej 23
1958 Frederiksberg C
Phone: +45 353-31646
Phone: +31 6 12189147
e-mail: <a class="moz-txt-link-abbreviated" href="mailto:pvb@life.ku.dk">pvb@life.ku.dk</a>
e-mail: <a class="moz-txt-link-abbreviated" href="mailto:p.vanbreugel@gmail.com">p.vanbreugel@gmail.com</a>
</pre>
</body>
</html>