[GRASSLIST:3352] Re: r.mapcalc problem

Paul Kelly paul-grass at stjohnspoint.co.uk
Tue May 4 21:08:24 EDT 2004


Hello

On Wed, 5 May 2004, Emiliano Giovanni Vavassori wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi all,
> My name is Emiliano and I'm an Agricultural Sciences student from Italy.
> GIS will eventually be useful to my profession, so I am trying to learn
> how to use this tool for territorial analysis. I read the GRASS Seeds
> tutorial by ASSIST and the GRASS Tutorial by M.Lennert, but maybe
> there's something (that) I don't understand with r.mapcalc.
> I tested GRASS 5.0.2, 5.0.3 and 5.3 on my Gentoo Linux Box, compiled

Well the tutorial clearly states that it is designed for GRASS 4.2 ;)

> from sources and ebuild to try to understand what the problem could be.
> I have also tried on a Debian Linux box with GRASS 5.0.3 with no
> positive results.
> The problem I am experiencing with GRASS is related to simple algebra
> map operations such as '+' and '-'. On page B-13 of the GRASS Seeds
> tutorial, the subsequent step is required:
>
> ~   r.mapcalc 'buffers = mwaybuf + railbuf' <enter>
>
> (well, the tutorial requires interactive mode, but that doesn't
> matter---I still have the same problem). At that time, the 'mwaybuf'
> raster map contains only a category, with number 1, that represents a
> buffer zone around a motorway. 'railbuf' also represents a buffer with
> category 2, but around railways. In those cases, the rest of the maps
> are 'no data' cells. My guess is that with a map addition I should
> expect to have a 'buffers' raster map that contains all buffers, marked
> with two different colours (if displayed with d.rast) and as well, in
> r.report there should be 2 categories, but what I obtain is an empty
> 'buffers' map, where all cells are marked 'no data'.

If either of the maps have 'no data' cells then the corresponding output
cell will also be 'no data'. So you will end up with a map with no data.
GRASS 4.x did not support null cells and just used zero. So you could add
the two maps like in the tutorial and it worked out fine.

I think you should try joining the maps using r.patch instead. Or convert
the null cells to 0 with
r.null mwaybuf null=0
r.null railbuf null=0
for both the maps and then the tutorial will work as designed with GRASS 5.x

Paul K




More information about the grass-user mailing list