[GRASS-dev] Floating and integer numbers in r.mapcalc

Paulo van Breugel p.vanbreugel at gmail.com
Wed Sep 24 02:14:37 PDT 2014


I have the following function (to calculate cell area)

PI=3.1415926536
RES=0.0008333
R=6371007
r.mapcalc "test3 = (sin(y()+$RES/2) - sin(y()-$RES/2)) * ($RES * $PI/180) *
$R^2"

This will give me a wrong results, apparently because R is an integer
value. If I adapt the formula:

r.mapcalc "test3 = (sin(y()+$RES/2) - sin(y()-$RES/2)) * ($RES * $PI/180) *
float($R)^2"

I get the correct result. From the help file I understand that if any of
the arguments is a floating number the result should be a floating number.
But that does not seem the case above so apparently I am missing something
here. Can anybody explain the logic behind the above?

Rgds

Paulo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20140924/e0764c64/attachment.html>


More information about the grass-dev mailing list