[GRASS-user] Select random cells from map

Hamish hamish_b at yahoo.com
Tue Jun 1 15:04:36 EDT 2010


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?

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.


good luck,
Hamish



      


More information about the grass-user mailing list