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

GRASS GIS trac at osgeo.org
Wed Jun 5 18:15:39 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   |  
--------------------------+-------------------------------------------------
Changes (by hamish):

  * keywords:  => r.mask


Comment:

 Hi,

 I can reproduce it,

 setup:
 {{{
 # fully null input map for r.mask:
 G65> g.region -d
 G65> r.mapcalc "allnull = null()"

 G65> r.info -r allnull
 min=NULL
 max=NULL
 }}}

 btw r.univar is broken for that, with --quiet you get no output at all!

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

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


 again, this time with partially null input map for r.mask:
 {{{
 G65> r.mapcalc "partnull = if(row() > 100, row(), null())"

 r.info -r partnull
 min=101
 max=477

 echo "* = 1" | r.reclass input=partnull output=partial.MASK.test

 G65> r.univar partial.MASK.test
 total null and non-null cells: 302418
 total null cells: 63400
 n: 239018
 minimum: 1
 maximum: 1
 }}}

 so it is a quirk of how r.reclass works. I'm not sure, but it seems like
 it could be an intended feature. One which should be documented in the man
 page of course...

 Keeping r.reclass as-is, here's a possible solution:

 {{{
 eval `r.info -r allnull`
 if [ "$min" = "NULL" -a "$max" = "NULL" ] ; then
    RECLASS_TO="NULL"
 else
    RECLASS_TO="1"
 fi
 echo "* = $RECLASS_TO" | r.reclass input="$GIS_OPT_INPUT" output=MASK
 }}}


 Hamish

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



More information about the grass-dev mailing list