Opened 10 years ago

Closed 4 years ago

#1977 closed defect (wontfix)

r.random.cells does not respect MASK

Reported by: pvanbosgeo Owned by: grass-dev@…
Priority: normal Milestone: 7.0.7
Component: Raster Version: svn-trunk
Keywords: r.random.cells, mask Cc:
CPU: Unspecified Platform: Unspecified

Description

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.

Change History (13)

comment:1 by hamish, 10 years ago

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

comment:2 by hamish, 10 years ago

Milestone: 6.4.37.0.0
Version: unspecifiedsvn-trunk

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

Hamish

comment:3 by pvanbosgeo, 10 years ago

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.

comment:4 by hamish, 10 years ago

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

in reply to:  description ; comment:5 by mmetz, 10 years ago

Replying to 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.

comment:6 by pvanbosgeo, 10 years ago

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.

in reply to:  5 ; comment:7 by hamish, 10 years ago

Replying to 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

in reply to:  7 comment:8 by mmetz, 10 years ago

Replying to hamish:

Replying to 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.

comment:9 by hamish, 10 years ago

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

regards, Hamish

comment:10 by martinl, 7 years ago

Milestone: 7.0.07.0.5

comment:11 by neteler, 6 years ago

Milestone: 7.0.57.0.6

comment:12 by neteler, 5 years ago

Milestone: 7.0.67.0.7

comment:13 by martinl, 4 years ago

Resolution: wontfix
Status: newclosed

No activity for a long time. Closing. Feel free to reopen if needed.

Note: See TracTickets for help on using tickets.