[GRASS-dev] MASK seems to be ignored

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.

(attachments)

Mask.png

sure not to do with the problem I had:

http://www.nabble.com/MASK-does-not-do-it's-work-(-%
29-with-r.mapcalc-td14407246.html#a14407246

I tried Glynn's method mentioned in that thread, specifically:

r.mapcalc MASK = '!isnull(MAP)'

which worked. Checking the range of the raster I used for a mask in my
r.mask command, it was 0-32767; so shouldn't r.mask in=MAP also create a mask
where any non-null cell in the input raster exists?

Here's the output from r.info for the mask I created using r.mask:

$ r.info MASK
+----------------------------------------------------------------------------+
| Layer: MASK Date: Tue Feb 5 11:53:33 2008 |
| Mapset: PERMANENT Login of Creator: epatton |
| Location: Charlottetown |
| DataBase: /home/epatton/Projects |
| Title: Reclass of EC_Charlottetown_Bathy_March_2007_1m_fill_shade_comb |
| Timestamp: none |
|----------------------------------------------------------------------------|
| |
| Type of Map: reclass Number of Categories: 1 |
| Data Type: CELL |
| Rows: 999 |
| Columns: 1220 |
| Total Cells: 1218780 |
| Projection: UTM (zone 20) |
| N: 5119638 S: 5118639 Res: 1 |
| E: 491266 W: 490046 Res: 1 |
| Range of data: min = 1 max = 1 |
| |
| Data Source: |
| Reclassified map based on: |
| Map [EC_Charlottetown_Bathy_March_2007_1m_fill_shade_comb] in mapset |
| |
| Data Description: |
| NT] |
| |
| Comments: |
| T] |
| |
|----------------------------------------------------------------------------|
| Reclassification of [EC_Charlottetown_Bathy_March_2007_1m_fill_shade_com |
| |
| Category Original categories |
| |
| 1 0-32737 |
+----------------------------------------------------------------------------+

~ Eric.

Patton, Eric wrote:

>sure not to do with the problem I had:
>
>http://www.nabble.com/MASK-does-not-do-it's-work-(-%
>29-with-r.mapcalc-td14407246.html#a14407246

I tried Glynn's method mentioned in that thread, specifically:

r.mapcalc MASK = '!isnull(MAP)'

which worked. Checking the range of the raster I used for a mask in my
r.mask command, it was 0-32767; so shouldn't r.mask in=MAP also create a mask
where any non-null cell in the input raster exists?

Here's the output from r.info for the mask I created using r.mask:

[snip]

MASK maps usually look like this. It would be more useful to see the
r.info output for the original map.

I'm assuming that the original does contain nulls (otherwise the
r.mapcalc method wouldn't do anything either). Is the original map a
reclass map?

The r.mapcalc method creates a completely new map, while r.mask
creates a reclass map. A reclass map takes much less space, but is
affected by any changes to the underlying map (which can be good or
bad, depending upon what you want), and may be susceptible to a
different set of bugs, quirks and corner cases than a normal
(non-reclass) map.

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

Checking the range of the raster I used for a mask in my
r.mask command, it was 0-32767; so shouldn't r.mask in=MAP also create a mask
where any non-null cell in the input raster exists?

Here's the output from r.info for the mask I created using r.mask:

MASK maps usually look like this. It would be more useful to see the
r.info output for the original map.

r.info output for original map from which the mask was created:

$ r.info Diff_Nov2007_Oct2007_1m
+----------------------------------------------------------------------------+
| Layer: Diff_Nov2007_Oct2007_1m Date: Mon Feb 4 14:10:04 2008 |
| Mapset: PERMANENT Login of Creator: epatton |
| Location: Charlottetown |
| DataBase: /home/epatton/Projects |
| Title: ( Diff_Nov2007_Oct2007_1m ) |
| Timestamp: none |
|----------------------------------------------------------------------------|
| |
| Type of Map: raster Number of Categories: 255 |
| Data Type: FCELL |
| Rows: 1136 |
| Columns: 1249 |
| Total Cells: 1418864 |
| Projection: UTM (zone 20) |
| N: 5119638 S: 5118502 Res: 1 |
| E: 491292 W: 490043 Res: 1 |
| Range of data: min = -2.809999 max = 1.246000 |
| |
| Data Description: |
| generated by r.mapcalc |
| |
| Comments: |
| EC_Charlottetown_Bathy_November_2007_1m_fill - |
| EC_Charlottetown_Bathy_October_2007_1m |
| |
+----------------------------------------------------------------------------+

I'm assuming that the original does contain nulls (otherwise the
r.mapcalc method wouldn't do anything either). Is the original map a
reclass map?

Yes, the original contains nulls. The original map is not a reclass, but the cell
values do cross through zero, if that matters.

The r.mapcalc method creates a completely new map, while r.mask
creates a reclass map. A reclass map takes much less space, but is
affected by any changes to the underlying map (which can be good or
bad, depending upon what you want), and may be susceptible to a
different set of bugs, quirks and corner cases than a normal
(non-reclass) map.

Good to know; I'll use the r.mapcalc method as it seems a bit more immune to
strangeness. I'll add some hints about this in the r.mask docs, too.

~ Eric.

Patton, Eric wrote:

>> Checking the range of the raster I used for a mask in my
>> r.mask command, it was 0-32767; so shouldn't r.mask in=MAP also create a mask
>> where any non-null cell in the input raster exists?
>>
>> Here's the output from r.info for the mask I created using r.mask:

>MASK maps usually look like this. It would be more useful to see the
>r.info output for the original map.

r.info output for original map from which the mask was created:

$ r.info Diff_Nov2007_Oct2007_1m
+----------------------------------------------------------------------------+
| Layer: Diff_Nov2007_Oct2007_1m Date: Mon Feb 4 14:10:04 2008 |
| Mapset: PERMANENT Login of Creator: epatton |
| Location: Charlottetown |
| DataBase: /home/epatton/Projects |
| Title: ( Diff_Nov2007_Oct2007_1m ) |
| Timestamp: none |
|----------------------------------------------------------------------------|
| |
| Type of Map: raster Number of Categories: 255 |
| Data Type: FCELL |

| Range of data: min = -2.809999 max = 1.246000 |

Reclassing is designed for integer maps. It's possible that there are
bugs or quirks when used with FP maps. In particular, there is
separate code to read the mask, so it's possible that reading a
particular map as a mask and reading it as a normal map (e.g.
"d.rast MASK") could produce different results.

I suggest using the r.mapcalc approach with FP maps.

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