[GRASS-dev] MASK seems to be ignored

On Feb 5, 2008, at 8:20 AM, grass-dev-request@lists.osgeo.org wrote:

Date: Tue, 5 Feb 2008 10:20:02 -0500
From: "Patton, Eric" <epatton@nrcan.gc.ca>
Subject: [GRASS-dev] MASK seems to be ignored
To: <grass-user@lists.osgeo.org>
Cc: grass-dev@lists.osgeo.org
Message-ID:
  <CA803441152AAE40935609509953BAD201075FB6@s0-ott-x4.nrn.nrcan.gc.ca>
Content-Type: text/plain; charset="iso-8859-1"

Hi,

I'm having problems getting a MASK to actually mask anything.

$ r.mask in=Diff_Nov2007_Oct2007_1m
MASK created. All subsequent raster operations
will be limited to MASK area
Removing or renaming raster file named MASK will
restore raster operations to normal
[Raster MASK present]

Yet all refreshes of the gis.m map display window do not clip the display extents
based on the new mask(see attached png). In the screenshot, the mask is the pink raster,
and underneath it is another raster in my mapset. Shouldn't the underlying raster's display
be clipped to that of the mask?

Using r.mapcalc while the mask exists also doesn't seem to obey the extents of the mask, i.e.:

r.mapcalc test = 'Diff_Oct2007_Mar2007_1m'

This creates the raster 'test' with data extents that match Diff_Oct2007_Mar2007_1m, not the mask's
boundaries.

I'm using svn-trunk compiled from today's source.

~ Eric.

Eric,

The way I understand it is that a MASK will affect all subsequent *read* operations for processing a raster map. That is...

r.mapcalc 'newmap=oldmap'

...will just produce an unaltered copy of oldmap without a MASK; with a MASK it will produce a copy of oldmap only in the area of MASK.

MASK will not affect the display. It is for map processing.

Michael

Hi,

[snip]
2008/2/5, Michael Barton <michael.barton@asu.edu>:

The way I understand it is that a MASK will affect all subsequent
*read* operations for processing a raster map. That is...

r.mapcalc 'newmap=oldmap'

...will just produce an unaltered copy of oldmap without a MASK; with
a MASK it will produce a copy of oldmap only in the area of MASK.

MASK will not affect the display. It is for map processing.

I was always thinking that masking *is* affecting the display...

g.region rast=elevation.dem;
r.mapcalc 'MASK=if(elevation.dem>1500,0,1)';
d.mon x0;
d.rast elevation.dem

Martin

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *

The way I understand it is that a MASK will affect all subsequent
*read* operations for processing a raster map. That is...

r.mapcalc 'newmap=oldmap'

...will just produce an unaltered copy of oldmap without a MASK; with
a MASK it will produce a copy of oldmap only in the area of MASK.

MASK will not affect the display. It is for map processing.

Michael

It seems that the current mask does affect the display, though. I've placed three
screenshots on ftp://gsca.nrcan.gc.ca/outgoing/Patton. The 'Before' image is the
full extent of my input raster; I zoomed into a small region in the display,
set the region to that of the display extent, and created a mask using r.mapcalc !isnull(MAP).
I then zoomed back to my original display extent, set the region back to that of
the display, and redrew the display, the output of which is the 'After' image.

The display is being clipped by the current mask.

~ Eric.

On Feb 5, 2008, at 9:48 AM, Patton, Eric wrote:

The way I understand it is that a MASK will affect all subsequent
*read* operations for processing a raster map. That is...

r.mapcalc 'newmap=oldmap'

...will just produce an unaltered copy of oldmap without a MASK; with
a MASK it will produce a copy of oldmap only in the area of MASK.

MASK will not affect the display. It is for map processing.

Michael

It seems that the current mask does affect the display, though. I've placed three
screenshots on ftp://gsca.nrcan.gc.ca/outgoing/Patton. The 'Before' image is the
full extent of my input raster; I zoomed into a small region in the display,
set the region to that of the display extent, and created a mask using r.mapcalc !isnull(MAP).
I then zoomed back to my original display extent, set the region back to that of
the display, and redrew the display, the output of which is the 'After' image.

The display is being clipped by the current mask.

Eric,

You are right. I stand corrected (or sit in this case).

Michael

~ Eric.

Michael Barton wrote:

> I'm having problems getting a MASK to actually mask anything.
>
> $ r.mask in=Diff_Nov2007_Oct2007_1m
> MASK created. All subsequent raster operations
> will be limited to MASK area
> Removing or renaming raster file named MASK will
> restore raster operations to normal
> [Raster MASK present]
>
> Yet all refreshes of the gis.m map display window do not clip the
> display extents
> based on the new mask(see attached png). In the screenshot, the
> mask is the pink raster,
> and underneath it is another raster in my mapset. Shouldn't the
> underlying raster's display
> be clipped to that of the mask?
>
> Using r.mapcalc while the mask exists also doesn't seem to obey the
> extents of the mask, i.e.:
>
> r.mapcalc test = 'Diff_Oct2007_Mar2007_1m'
>
> This creates the raster 'test' with data extents that match
> Diff_Oct2007_Mar2007_1m, not the mask's
> boundaries.
>
> I'm using svn-trunk compiled from today's source.
>
> ~ Eric.

Eric,

The way I understand it is that a MASK will affect all subsequent
*read* operations for processing a raster map.

Correct.

That is...

r.mapcalc 'newmap=oldmap'

...will just produce an unaltered copy of oldmap without a MASK; with
a MASK it will produce a copy of oldmap only in the area of MASK.

MASK will not affect the display. It is for map processing.

As you've already noticed, MASK *will* affect the display. You can't
display a map without reading it, and MASK affects all raster read
operations unless they explicitly choose to avoid it by using the
G_get_*_row_nomask() functions.

FWIW, the following modules use the G_get_*_row_nomask() functions:

imagery/i.class
imagery/i.ortho.photo
imagery/i.points
imagery/i.rectify
imagery/i.vpoints
ps/ps.map
raster/r.basins.fill
raster/r.buffer
raster/r.cats
raster/r.compress
raster/r.describe
raster/r.le
raster/r.null
raster/r.random.cells
raster/r.random.surface
raster/r.recode
raster/r.rescale
raster/r.slope.aspect
raster/r.support.stats
raster/r.surf.contour
raster/r.surf.idw
raster/r.surf.idw2
raster/r.watershed

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