[GRASSLIST:1219] Re: Combining raster layers with r.mapcalc

Roger Bivand Roger.Bivand at nhh.no
Fri Sep 12 15:36:08 EDT 2003


On Fri, 12 Sep 2003, Paul Kelly wrote:

> 
> 
> On Fri, 12 Sep 2003, Bill Dickinson Jr wrote:
> 
> > Hey there:
> >
> > In running through the SEEDS tutorial, one of the tasks is combining
> > two raster layers into a single raster using r.mapcalc. The
> > individual layers show the data properly, but the resulting combined
> > layer contains no data. Here is what I do:
> 
> This is *probably* because the tutorial was written for GRASS 4.x where
> there was no concept of a NULL value, only zero. In GRASS 5.x r.mapcalc,
> where any part of the input maps contains no data, the output will have no
> data. See here for a fuller discussion (and why the tutorial cannot be
> updated):
> http://intevation.de/rt/webrt?serial_num=1338
> 

Yes, it's because the zeros in the input rasters are being converted to 
NULL. Another way round is:

r.mapcalc "try1 = isnull(rail)"
r.mapcalc "rail1 = if(try1, 0, 1, 0)"

or equivalently:

r.mapcalc "rail1 = if(isnull(rail), 0, 1, 0)"

and the same for mway.

> Maybe use r.patch instead?

r.patch is more elegant, though:

r.patch input=railbuf,mwaybuf output=buffers

Roger

> 
> Paul
> 
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no




More information about the grass-user mailing list