[GRASS-user] Re: Select random cells from map

Marcello Gorini gorini at gmail.com
Tue Jun 1 08:12:24 EDT 2010


>>António Rocha:
>>Hi there
>>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?

Hello Antônio,

This one I think I can help.
There is this command "v.random" that allows you to create a vector
containing random points in your current region. And you can control the
number of points with the parameter "n". Than you can upload the vector
database with values from any raster with the command "v.what.rast" and than
export it to a file if you want.

The manual has this clarifying example:

v.random output=random_samples n=20
v.db.addtable map=random_samples layer=1 columns='cat INTEGER, sample DOUBLE
PRECISION'
v.what.rast vector=random_samples raster=elevation.10m at PERMANENT layer=1
column=sample 

However, I believe that if you have null cells in your raster and some of
the random points happen to fall over them, you will have less valid points
than you expect, so I would say that you should check the resultant
database.

Hope this helps.
Best regards,

Marcello.

-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Select-random-cells-from-map-tp5125298p5125703.html
Sent from the Grass - Users mailing list archive at Nabble.com.


More information about the grass-user mailing list