[GRASS-user] using r.mapcalc

Glynn Clements glynn at gclements.plus.com
Fri Feb 9 12:29:14 EST 2007


Thomas Drüssler wrote:

> please help me solving a problem concerning r.mapcalc:
> my intention is to calculate a new map consisting of two older ones. the one 
> shows  digitized elements( rocks), cat values are NULL or 1, 
> the other is a reclassified map(slope >50), with cat values 1 or NULL. 
> so i have 4 options:
> pixels, with only digitized elements, pixels with only slope elements, pixels with both and pixels without(NULL)
> the resulting map sould consist of these 4 categories.
> i already tried r.patch, but with no success, there was only one resulting category and NULL values.

	r.mapcalc 'out = !isnull(map1) + 2 * !isnull(map2)'

In general, it's easier to work with 0/1 for "boolean" maps rather
than null/1.

In GRASS, a null value means "no data" or "unknown". IOW, null *isn't*
interpreted as a specific category or value, but as a "marker" for an
unknown value.

E.g. in your second example map, if a value of 1 means that slope>50,
then the "natural" interpretation of a null value is that it is
unknown whether or not slope>50, *not* that slope<=50.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-user mailing list