[GRASS-user] geometric mean with r.mapcalc

Hamish hamish_b at yahoo.com
Tue Jun 17 08:50:32 EDT 2008


Valentina wrote:
> I tried to calculate the geometric mean with float numbers
> for six raster maps, but the result was a map with only one
> value: 1.0.
> I used the formula: (A*B*C*D*E*F) ^ (1/6),  and also: 
> pow((A*B*C*D*E*F), (1/6))   but I get always the same result: 1.0.
> Could somebody help me?


try:  pow((A*B*C*D*E*F), (1/6.0))

The result of an integer/integer calculation is an integer, so 0.166667 is truncated to 0 and the result will be x^0, which is always equal to 1.

In this manner r.mapcalc just follows what the C programming language does, the quirk is not really specific to r.mapcalc or GRASS.


Hamish



      



More information about the grass-user mailing list