Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#2032 closed defect (invalid)

r.mapcalc does not always respect MASK

Reported by: pvanbosgeo Owned by: grass-dev@…
Priority: normal Milestone: 7.0.0
Component: Raster Version: unspecified
Keywords: r.mapcalc Cc:
CPU: Unspecified Platform: Linux

Description

If I run:

r.mask raster=mymask
r.mapcalc "test1 = 1"
r.mapcalc "test2 = test1"
r.mask -r

The layer test1 has value 1 for all raster cells within the current region. In layer test2 only cells within the masked area have the value 1, cells outside the mask have nodata, as I would expect.

Running GRASS 7.0 rv 57144 on Ubuntu 13.04

Change History (3)

in reply to:  description comment:1 by mmetz, 11 years ago

Resolution: invalid
Status: newclosed

Replying to pvanbosgeo:

If I run:

r.mask raster=mymask
r.mapcalc "test1 = 1"
r.mapcalc "test2 = test1"
r.mask -r

The layer test1 has value 1 for all raster cells within the current region. In layer test2 only cells within the masked area have the value 1, cells outside the mask have nodata, as I would expect.

From the raster intro [0]: "Raster input maps are automatically masked if a raster map named MASK exists. The MASK is only applied when reading maps from the disk."

A MASK is not applied when writing out files. If you set the output cell value to constant 1, all output cells will have the value 1, even if a MASK was set while writing the output raster.

[0] http://grass.osgeo.org/grass70/manuals/rasterintro.html

comment:2 by pvanbosgeo, 11 years ago

OK, thanks, I didn't know that / hadn't read that part of the manual carefully enough. Perhaps not something that the user will encounter often, but nonetheless, it is something I can see others might overlook as well when using r.mapcalc. Perhaps a short note of this can be added to the r.mapcalc help file (which is where I looked to see where my expectations of the behavior of r.mapcalc were wrong)?

in reply to:  2 comment:3 by glynn, 11 years ago

Replying to pvanbosgeo:

OK, thanks, I didn't know that / hadn't read that part of the manual carefully enough. Perhaps not something that the user will encounter often, but nonetheless, it is something I can see others might overlook as well when using r.mapcalc. Perhaps a short note of this can be added to the r.mapcalc help file (which is where I looked to see where my expectations of the behavior of r.mapcalc were wrong)?

The behaviour isn't specific to r.mapcalc. Except for a few special cases, the MASK behaviour isn't implemented by the individual modules, but by the raster I/O library. You can observe the same behaviour with e.g. r.neighbors.

The correct place to document this behaviour is wherever the MASK behaviour is described, e.g. the rasterintro manual page and the r.mask manual page. FWIW, the first sentence of the DESCRIPTION section of the r.mask manual page (after the summary) is:

The MASK is only applied when reading an existing GRASS raster map,
for example when used in a module as an input map.
Note: See TracTickets for help on using tickets.