[GRASS-dev] [GRASS GIS] #1999: r.mask with NULL map doesn't work

GRASS GIS trac at osgeo.org
Fri Jun 7 02:02:07 PDT 2013


#1999: r.mask with NULL map doesn't work
--------------------------+-------------------------------------------------
 Reporter:  ferrouswheel  |       Owner:  grass-dev@…              
     Type:  defect        |      Status:  new                      
 Priority:  normal        |   Milestone:  6.4.3                    
Component:  Raster        |     Version:  svn-develbranch6         
 Keywords:  r.mask        |    Platform:  Linux                    
      Cpu:  Unspecified   |  
--------------------------+-------------------------------------------------

Comment(by glynn):

 Replying to [comment:1 hamish]:

 > what r.mask does:
 {{{
 G65> echo "* = 1" | r.reclass input=allnull output=MASK.test

 G65> r.info -r MASK.test
 min=1
 max=1
 }}}

 The range file generated by r.reclass is based upon the range of values in
 the reclass table, regardless of the values present in the base map. E.g.:
 {{{
 $ r.mapcalc --o 'foo = 2'
 $ r.reclass --o in=foo out=bar rules=-
 Enter rule(s), "end" when done, "help" if you need it
 CELL: Data range is 2 to 2
 > 1 = 1
 > 2 = 2
 > 3 = 3
 > end
 $ r.info -r bar
 min=1
 max=3
 }}}

 However, that isn't the real problem here.

 1. A map which is a reclass of an all-null map is read as all-null:
 {{{
 $ echo "* = 1" | r.reclass input=allnull output=testmask rules=-
 $ r.mapcalc --o 'foo = testmask'
 $ r.info -r foo
 min=NULL
 max=NULL
 }}}

 2. A MASK map which is a reclass of an all-null map doesn't mask anything
 out:
 {{{
 $ echo "* = 1" | r.reclass input=allnull output=MASK rules=-
 $ r.mapcalc --o 'foo = elevation.dem'
 $ g.remove rast=MASK
 $ r.info -r foo
 min=1066
 max=1840
 }}}

 3. A (non-reclass) all-null MASK map masks everything out:
 {{{
 $ r.mapcalc 'MASK = allnull'
 $ r.mapcalc --o 'foo = elevation.dem'
 $ g.remove rast=MASK
 $ r.info -r foo
 min=NULL
 max=NULL
 }}}

 Clearly, the code in lib/raster/get_row.c which reads a MASK map doesn't
 handle reclass maps correctly.

 Specifically, embed_mask() calls get_map_row_nomask() then, if it's a
 reclass map, do_reclass_int(). Finally, any cell whose value is zero is
 marked as null.

 However, get_map_row_nomask() doesn't embed nulls (so any nulls will be
 read as zero). When the mask isn't a reclass, this works okay, as nulls
 are stored with zero as the cell value. But do_reclass_int() expects nulls
 to have been embedded; a zero will be treated as such and reclassed.

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/1999#comment:2>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list