v.random can generate also 3D vector points or write random value to attribute table. Point height range or attribute value range is controlled by specifying zmin and zmax values. Both z values are included in range (zmin <= z <= zmax). Generated random attribute value type can be controlled by column data type. Use INTEGER column type for integers and DOUBLE PRECISION for floating point numbers. Integer values are calculated by rounding random floating point number.
To produce repeatable results a random seed can be set using the option seed.
If an input vector map with areas is specified, the location of random points is restricted to the selected areas. By default, the requested number of points are distributed across all areas.
If the -a flag is given, the requested number of points is generated for each individual area. For example, if 20 points should be generated and the input map has 100 individual areas, 2000 points will be generated in total.
Generate 20 random points with binary attribute (only 0 or 1):
v.random output=binary_random n=20 zmin=0 zmax=1 column='binary INTEGER'
v.random seed=501 output=height_random n=20 zmin=0 zmax=1 column=height
g.region -p rast=elevation 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@PERMANENT layer=1 column=sample
g.region -p vect=geology v.random output=random_samples n=20 v.db.addtable map=random_samples layer=1 columns='cat integer, geology varchar(100)' v.what.vect vector=random_samples layer=1 column=geology qvector=geology@PERMANENT qlayer=1 qcolumn=label
g.region -p rast=landclass96 r.to.vect -v input=landclass96 output=landclass96 type=area v.random input=landclass96 output=random_samples n=20 where="label = 'forest'"
g.region -p rast=landclass96 r.to.vect -v input=landclass96 output=landclass96 type=area v.random input=landclass96 output=random_samples n=20 where="label = 'forest'" -a
g.region, r.random, v.perturb, v.sample v.what.rast v.what.vect
Last changed: $Date$