[GRASS-user] How to initialize raster maps.

Moritz Lennert mlennert at club.worldonline.be
Thu Dec 8 17:04:35 EST 2011

On 08/12/11 22:26, Marcello Gorini wrote:
> Dear all,
> Inside a loop in a shell script, I keep incrementing the values of a raster
> map using r.mapcalc with some logical expressions.
> Therefore, I need to initialize the raster map before the loop itself.
> Ideally, I would like to initialize it as a raster with the same dimensions
> as my base map, but containing only zeros.
> In order to do that, I use the following expression:
> r.mapcalc "initialized_map=if(base_map>999999,1,0)"
> Besides being one of the ugliest pieces of code one could ever write, it
> also incurs in waste of processing time.
> Which would be a more elegant and optimized way of initializing these raster
> maps?
> Thanks in advance for any thoughts you could share.

g.region rast=YourBaseMap
r.mapcalc initialized_map=0


More information about the grass-user mailing list