Re: [GRASS-user] Mapcalc for rounding float values

2013-02-14 Thread Rebecca Bennett
Dear GRASS-Users, I have a map of local elevation that I would like to alter the values of and re-class as a experiment to aid visualisation & interpretation. 1) Currently the cells are floating point with z-values like 0.0151666768416021 - I would like to do is round the elevation values to 2

Re: [GRASS-user] Mapcalc for rounding float values

2013-02-14 Thread Hamish
Rebecca wrote: > I have a map of local elevation that I would like to alter the > values of and re-class as a experiment to aid visualisation & > interpretation. firstly, the r.reclass module might help, as may r.contour. > 1) Currently the cells are floating point with z-values like > 0.01516667

Re: [GRASS-user] Mapcalc for rounding float values

2013-02-14 Thread Hamish
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

Re: [GRASS-user] Mapcalc for rounding float values

2013-02-15 Thread Glynn Clements
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. Note that r.mapcalc has a round() function. -- Glynn Clements ___

Re: [GRASS-user] Mapcalc for rounding float values

2013-02-15 Thread Margherita Di Leo
Hi, On Fri, Feb 15, 2013 at 2:09 PM, Glynn Clements wrote: > > 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. > > Note that r.mapcalc has a round()