[GRASS-dev] [GRASS GIS] #1525: r.mask cannot use float maps

GRASS GIS trac at osgeo.org
Thu Dec 29 10:26:06 EST 2011

#1525: r.mask cannot use float maps
 Reporter:  pertusus  |       Owner:  grass-dev@…              
     Type:  defect    |      Status:  new                      
 Priority:  normal    |   Milestone:  7.0.0                    
Component:  Raster    |     Version:  svn-trunk                
 Keywords:            |    Platform:  Linux                    
      Cpu:  x86-64    |  
 In the r.mask documentation it is said

 The mask is read as an integer map. If MASK is actually a
 floating-point map, the values will be converted to integers using the
 map's quantisation rules (this defaults to round-to-nearest, but can
 be changed with r.quant).

 But if trying to do a mask with a float raster map, there is an error

 echo "0|0|1" | r.in.xyz input=- output=seed
 r.mask input=seed
 ERROR: Raster map seed must be integer for maskcats parameter

 Usint r.quant do not change anything (poking in the dark here, I don't
 really understand why r.quant do not need an output map).

 r.quant -t seed
 r.mask input=seed
 ERROR: Raster map seed must be integer for maskcats parameter

 A tarball is attached to reproduce the issue.

 I had a look at r.mask and r.mask for 6.4.1, besides being a python
 script, the difference seems to be that in the svn version there is a test
 that the map is indeed a CELL map, which fails and give the error message,
 while there was no such test in the shell script.  The code is along

       if grass.raster_info(input)['datatype'] != "CELL":
             grass.fatal(_("Raster map %s must be integer for maskcats
 parameter") % input)

 I have tried without that check and things seems to work.  I also attach a
 trivial patch that comment that code out.  Maybe r.reclass does the magic
 float to integer quantification stuff?  If it is the case, a comment in
 the code, like

 # r.reclass takes care of float to integer translation

 could be handy.

 Maybe the problem is in the doc and really only integer raster map with
 type CELL may be used, but then the doc has to be changed and it would be
 nice to have a direction, the reference to r.quant not being very useful,
 in my opinion.

Ticket URL: <http://trac.osgeo.org/grass/ticket/1525>
GRASS GIS <http://grass.osgeo.org>

More information about the grass-dev mailing list