[GRASS-user] Select random cells from map

> António wrote:
>> I need to randomly select non-null cells from a given map.
>> I tried r.random.cells but I cannot define a maximum number
>> random cells and some selected random cells are not valid
>> values in my map. is there any other function to randomly
>> select cells from a raster?

Hamish:

> r.to.vect to get a vector area coverage of your raster (do
> not use the -s flag), then v.random.cover from wiki addons
> then v.to.rast, and finally r.mapcalc to transfer values from
> source map to random cell map? (probably we/I should make a
> new wrapper script to do that automatically)
>
> or you might skip the last steps and just use v.random.cover's
> raster= option to sample the raster map directly.
>
> probably the best idea is to fix r.random's cover= option to
> loop until it has enough points.
>
>
> also if you will be doing a lot of geostats it is probably
> worth your while to learn about the GRASS<->R interface:
> http://grass.osgeo.org/wiki/R_statistics
>
> ... then the world is open to you.

António wrote:

Thanks for your answer. I tried r.random with my input data and the
number of cells and it worked but I do have one question: I didn't
understand the objective of cover_map. I used the map from I want to
extract random cells as input but what is the objective of cover_map?

r.random creates random points all over the current rectangular region
block.

Adding a cover map makes those random points only occur within the
irregular area covered by the cover map. (but r.random cover= is a bit
buggy right now; see new ticket in the bug trac'er)

Hamish

Thanks Hamish
I thought that random cells are retrieved from valid "map" cells. Or not?
Antonio

Hamish wrote:

António wrote:
      

I need to randomly select non-null cells from a given map.
I tried r.random.cells but I cannot define a maximum number
random cells and some selected random cells are not valid
values in my map. is there any other function to randomly
select cells from a raster?
        
Hamish:
  
r.to.vect to get a vector area coverage of your raster (do
not use the -s flag), then v.random.cover from wiki addons
then v.to.rast, and finally r.mapcalc to transfer values from
source map to random cell map? (probably we/I should make a
new wrapper script to do that automatically)

or you might skip the last steps and just use v.random.cover's
raster= option to sample the raster map directly.

probably the best idea is to fix r.random's cover= option to
loop until it has enough points.

also if you will be doing a lot of geostats it is probably
worth your while to learn about the GRASS<->R interface:
http://grass.osgeo.org/wiki/R_statistics

... then the world is open to you.
      
António wrote:
  
Thanks for your answer. I tried r.random with my input data and the number of cells and it worked but I do have one question: I didn't understand the objective of cover_map. I used the map from I want to extract random cells as input but what is the objective of cover_map?
    
r.random creates random points all over the current rectangular region
block.

Adding a cover map makes those random points only occur within the
irregular area covered by the cover map. (but r.random cover= is a bit
buggy right now; see new ticket in the bug trac'er)

Hamish

__________ Information from ESET NOD32 Antivirus, version of virus signature database 5177 (20100606) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

__________ Information from ESET NOD32 Antivirus, version of virus signature database 5178 (20100607) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com