[GRASS-user] Mapcalc for rounding float values

Hamish hamish_b at yahoo.com
Thu Feb 14 16:14:24 PST 2013


Hamish wrote:
> there are a couple ways to do it, here's one:
>   r.mapcalc "map.2dp = int(0.5 + (map.15g * 100))/100.0"
> 
> the 0.5 is added because int() truncates instead of
> rounding.

mind that if your values go negative, int() and floor() are
not the same..

> another common way is with log(mapname,10), but the above
> may be a little more obvious.

maybe that way still helps though.


Hamish


More information about the grass-user mailing list