[GRASS-user] MASK does not do it's work (?) with r.mapcalc -- Again!

Glynn Clements glynn at gclements.plus.com
Tue Jan 22 23:18:54 EST 2008


nikos.alexandris at felis.uni-freiburg.de wrote:

> Thank you for the attention Moritz.
> 
> I understand MASK as a boolean map with (let's say) "1"
> (for true) and "0" (for false).
> 
> The r.info (the one I provided in my previous e-mail) is
> about the raster data I want to use to create a MASK and
> not the MASK itself.
> 
> Should I understand that only "integer" raster data are
> suitable to create a MASK?

The mask is read as an integer map. If MASK is actually a
floating-point map, the values will be converted to integers using the
map's quantisation rules (this defaults to round-to-nearest, but can
be changed with r.quant).

Your NDVI20060.35 map has a range of 0.001304 to 0.349991, so all of
those values will be rounded to zero.

> I understand (reading the r.mapcalc functionality) that one
> can use any kind of raster data (floating point) and create
> a MASK which contains a "1" for the pixels that have any
> value besides "NULL".
> 
> So I expected to have a "1" wherever there was a value in
> my NDVI2006 file.
> 
> Maybe I use it wrong(?)
> 
> Should I specify to assign a value of "1" for all non-NULL
> source pixels?
> 
> I'll try with "mask = a != 0" as described in the r.mapcalc
> manual.

If you want to create a mask based upon null/non-null, use e.g.:

	r.mapcalc "MASK = !isnull(inmap)"

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


More information about the grass-user mailing list