[GRASS-dev] [GRASS GIS] #1977: r.random.cells does not respect MASK

#1977: r.random.cells does not respect MASK
----------------------------------+-----------------------------------------
Reporter: pvanbosgeo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.3
Component: Raster | Version: unspecified
Keywords: r.random.cells, mask | Platform: Unspecified
      Cpu: Unspecified |
----------------------------------+-----------------------------------------
In the helpfile of r.random.cells, it is mentioned that "Random cells will
not be generated in areas masked off". However, in reality the function
does not (seem to) respect the MASK.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1977&gt;
GRASS GIS <http://grass.osgeo.org>

#1977: r.random.cells does not respect MASK
----------------------------------+-----------------------------------------
Reporter: pvanbosgeo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.3
Component: Raster | Version: unspecified
Keywords: r.random.cells, mask | Platform: Unspecified
      Cpu: Unspecified |
----------------------------------+-----------------------------------------

Comment(by hamish):

Works for me -- random cells are only created in the MASKed areas. the
areas not covered by the MASK map are flood filled with "0". (use "r.null
setnull=0" to clear that away)

{{{
#spearfish
g.region rast=fields
g.copy fields,MASK
r.random.cells out=test.rrandcellsMASKed dist=500
g.remove MASK
}}}

... and random points only occur in places covered by the MASK map.

was your MASK map a CELL (integer) type?

see also the v.random.cover addon module, which may do something like what
you are looking for.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1977#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#1977: r.random.cells does not respect MASK
----------------------------------+-----------------------------------------
Reporter: pvanbosgeo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Raster | Version: svn-trunk
Keywords: r.random.cells, mask | Platform: Unspecified
      Cpu: Unspecified |
----------------------------------+-----------------------------------------
Changes (by hamish):

  * version: unspecified => svn-trunk
  * milestone: 6.4.3 => 7.0.0

Comment:

... works for me on linux in 6.4.3svn (as per the milestone), but not
trunk.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1977#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#1977: r.random.cells does not respect MASK
----------------------------------+-----------------------------------------
Reporter: pvanbosgeo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Raster | Version: svn-trunk
Keywords: r.random.cells, mask | Platform: Unspecified
      Cpu: Unspecified |
----------------------------------+-----------------------------------------

Comment(by pvanbosgeo):

Ah, yes, its not working for me on trunk. Sorry for the wrong milestone
and not mentioning this was with grass 7. The mentioned add-on works, but
it does not enforce a minimal spacing between points as far as I can see.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1977#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#1977: r.random.cells does not respect MASK
----------------------------------+-----------------------------------------
Reporter: pvanbosgeo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Raster | Version: svn-trunk
Keywords: r.random.cells, mask | Platform: Unspecified
      Cpu: Unspecified |
----------------------------------+-----------------------------------------

Comment(by hamish):

ok, for now the GRASS 6.x version or r.random.cells should work fine as a
work-around.

no, v.random.cover doesn't enforce minimal spacing currently (feel free to
file a wish for that).

thanks for reporting it,
Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1977#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#1977: r.random.cells does not respect MASK
----------------------------------+-----------------------------------------
Reporter: pvanbosgeo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Raster | Version: svn-trunk
Keywords: r.random.cells, mask | Platform: Unspecified
      Cpu: Unspecified |
----------------------------------+-----------------------------------------

Comment(by mmetz):

Replying to [ticket:1977 pvanbosgeo]:
> In the helpfile of r.random.cells, it is mentioned that "Random cells
will not be generated in areas masked off". However, in reality the
function does not (seem to) respect the MASK.

Try r56375. The bug comes from the times when zero was regarded as NULL.
Actually it should not work either in 6.x because for CELL_TYPE NULL != 0.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1977#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#1977: r.random.cells does not respect MASK
----------------------------------+-----------------------------------------
Reporter: pvanbosgeo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Raster | Version: svn-trunk
Keywords: r.random.cells, mask | Platform: Unspecified
      Cpu: Unspecified |
----------------------------------+-----------------------------------------

Comment(by pvanbosgeo):

Great, it works now, with the note that all cells other than the random
points (cells) have the value 0, including all cells outside the masked
area. That is fine, although a suggestion might be to set all cells,
except obviously the random points, to NULL, like r.random does.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1977#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#1977: r.random.cells does not respect MASK
----------------------------------+-----------------------------------------
Reporter: pvanbosgeo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Raster | Version: svn-trunk
Keywords: r.random.cells, mask | Platform: Unspecified
      Cpu: Unspecified |
----------------------------------+-----------------------------------------

Comment(by hamish):

Replying to [comment:5 mmetz]:
> Actually it should not work either in 6.x because for CELL_TYPE NULL !=
0.

and yet it does work there.

perhaps because it uses G_get_map_row_nomask()?

shrug,
Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1977#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#1977: r.random.cells does not respect MASK
----------------------------------+-----------------------------------------
Reporter: pvanbosgeo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Raster | Version: svn-trunk
Keywords: r.random.cells, mask | Platform: Unspecified
      Cpu: Unspecified |
----------------------------------+-----------------------------------------

Comment(by mmetz):

Replying to [comment:7 hamish]:
> Replying to [comment:5 mmetz]:
> > Actually it should not work either in 6.x because for CELL_TYPE NULL
!= 0.
>
> and yet it does work there.
>
> perhaps because it uses G_get_map_row_nomask()?

Trunk uses Rast_get_c_row_nomask().

I created a MASK that contains only NULL and 1, no zero. Therefore I think
it is a bug in G_get_map_row_nomask() of 6.x, converting NULL to zero.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1977#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>

#1977: r.random.cells does not respect MASK
----------------------------------+-----------------------------------------
Reporter: pvanbosgeo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Raster | Version: svn-trunk
Keywords: r.random.cells, mask | Platform: Unspecified
      Cpu: Unspecified |
----------------------------------+-----------------------------------------

Comment(by hamish):

seeing that all is working fine in 6.x I'd err on the side of not messing
with it.

regards,
Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1977#comment:9&gt;
GRASS GIS <http://grass.osgeo.org>