[GRASS-dev] r.mask: odd behavior?

Hi devs,

I found that r.mask does not behave as I would expect and I would really appreciate some clarification.

The issue is the following: I apply a mask, then I do some processing, I remove the mask and when I display the resulting map, all the pixels were processed. I would expect that those pixels that I masked were treated as NULL and not considered exactly as the message says:

“All subsequent raster operations will be limited to the MASK area. Removing
or renaming raster map named ‘MASK’ will restore raster operations to
normal.”

Otherwise, what’s the point of applying a mask?

This is an example with NC:

g.region raster=landcover_1m -p
r.category landcover_1m
r.mask raster=landcover_1m maskcats=“1 thru 6”
d.mon wx0
d.rast landcover_1m
r.mapcalc “applied_mask = 1”
r.mask -r
d.erase
d.rast applied_mask <<-- everything is there, no holes…

The only operation that gave me what I would expect when I apply a mask was:

r.mapcalc expression=“applied_mask=1-MASK”

Can someone, please, test/clarify this?

thanks much in advance!

Vero

On Sun, Nov 19, 2017 at 9:19 PM, Veronica Andreo <veroandreo@gmail.com> wrote:

Hi devs,

I found that r.mask does not behave as I would expect and I would really appreciate some clarification.

The issue is the following: I apply a mask, then I do some processing, I remove the mask and when I display the resulting map, all the pixels were processed. I would expect that those pixels that I masked were treated as NULL and not considered exactly as the message says:

“All subsequent raster operations will be limited to the MASK area. Removing
or renaming raster map named ‘MASK’ will restore raster operations to
normal.”

A MASK affects only reading raster data, not writing raster data. Therefore r.mapcalc “test = 1” will always produce a map without NULL cells.

Markus M

Otherwise, what’s the point of applying a mask?

This is an example with NC:

g.region raster=landcover_1m -p
r.category landcover_1m
r.mask raster=landcover_1m maskcats=“1 thru 6”
d.mon wx0
d.rast landcover_1m
r.mapcalc “applied_mask = 1”
r.mask -r
d.erase
d.rast applied_mask <<-- everything is there, no holes…

The only operation that gave me what I would expect when I apply a mask was:
r.mapcalc expression=“applied_mask=1-MASK”

Can someone, please, test/clarify this?

thanks much in advance!
Vero


grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev

Hi Markus,

···

The issue is the following: I apply a mask, then I do some processing, I remove the mask and when I display the resulting map, all the pixels were processed. I would expect that those pixels that I masked were treated as NULL and not considered exactly as the message says:

“All subsequent raster operations will be limited to the MASK area. Removing
or renaming raster map named ‘MASK’ will restore raster operations to
normal.”

A MASK affects only reading raster data, not writing raster data. Therefore r.mapcalc “test = 1” will always produce a map without NULL cells.

Got it! That r.mapcalc expression was not reading any map. If I do for example

r.mapcalc expression=“elev1=elevation + 1”

and then remove the mask, it does work as I would have expected.

IMHO, the message is confusing then… not “all” subsequent raster operations are limited to the mask, only if you read a map…

What about a mask also for writing raster data in GRASS 8 ? :))

cheers,

Vero

2017-11-19 22:08 GMT+01:00 Veronica Andreo <veroandreo@gmail.com>:

Hi Markus,

> The issue is the following: I apply a mask, then I do some processing, I

remove the mask and when I display the resulting map, all the pixels were
processed. I would expect that those pixels that I masked were treated as
NULL and not considered exactly as the message says:

>

> "All subsequent raster operations will be limited to the MASK area.
Removing
> or renaming raster map named 'MASK' will restore raster operations to
> normal."

A MASK affects only reading raster data, not writing raster data.
Therefore r.mapcalc "test = 1" will always produce a map without NULL cells.

Got it! That r.mapcalc expression was not reading any map. If I do for
example

r.mapcalc expression="elev1=elevation + 1"

and then remove the mask, it does work as I would have expected.

IMHO, the message is confusing then... not "all" subsequent raster
operations are limited to the mask, only if you read a map...
What about a mask also for writing raster data in GRASS 8 ? :))

I have added it here: https://trac.osgeo.org/grass/wiki/Grass8Planning
Maybe someone else thinks this would be useful :slight_smile:

Vero

On November 20, 2017 11:45:57 AM Veronica Andreo veroandreo@gmail.com wrote:

2017-11-19 22:08 GMT+01:00 Veronica Andreo veroandreo@gmail.com:

Hi Markus,

The issue is the following: I apply a mask, then I do some processing, I
remove the mask and when I display the resulting map, all the pixels were
processed. I would expect that those pixels that I masked were treated as
NULL and not considered exactly as the message says:

“All subsequent raster operations will be limited to the MASK area.
Removing
or renaming raster map named ‘MASK’ will restore raster operations to
normal.”

A MASK affects only reading raster data, not writing raster data.
Therefore r.mapcalc “test = 1” will always produce a map without NULL cells.

Got it! That r.mapcalc expression was not reading any map. If I do for
example

r.mapcalc expression=“elev1=elevation + 1”

and then remove the mask, it does work as I would have expected.

IMHO, the message is confusing then… not “all” subsequent raster
operations are limited to the mask, only if you read a map…
What about a mask also for writing raster data in GRASS 8 ? :))

I have added it here: https://trac.osgeo.org/grass/wiki/Grass8Planning
Maybe someone else thinks this would be useful :slight_smile:

+1

Vero



grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev


Send from my mobile
Excuse my brevity