123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <h2>DESCRIPTION</h2>
- <em>v.random</em> randomly generates vector points within the
- current region using the selected random number generator.
- <p><em>v.random</em> 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 (<em>zmin <= z <= zmax</em>).
- Generated random attribute value type can be controlled by column
- data type. Use <b>INTEGER</b> column type for integers and
- <b>DOUBLE PRECISION</b> for floating point numbers. Integer values are
- calculated by rounding random floating point number.
- <p>To produce repeatable results a random seed can be set using the
- option <em>seed</em>.
- <h3>Restriction to vector areas</h3>
- <p>
- If an <em>input</em> 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.
- <p>
- If the <em>-a</em> 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.
- <h2>EXAMPLES</h2>
- All examples use the North Carolina sample dataset.
- <p>
- Generate 20 random points with binary attribute (only 0 or 1):
- <div class="code"><pre>
- v.random output=binary_random npoints=20 zmin=0 zmax=1 column='binary INTEGER'
- </pre></div>
- Generate 20 random 3D points using a specific random seed:
- <div class="code"><pre>
- v.random seed=52 output=height_random npoints=40 zmin=110 zmax=170 -z
- </pre></div>
- <p>
- <center>
- <img src="vrandom_z.png"><br>
- Random points with different X, Y, and Z coordinates
- </center>
- <!--
- g.region rast=elev_lid792_1m
- ...
- d.vect height_random color=60:60:60 icon=basic/point size=40 width=2 zcolor=gyr
- optipng -o5 map.png
- mv map.png vrandom_z.png
- -->
- Get 20 random samples from raster map:
- <div class="code"><pre>
- g.region -p raster=elevation
- v.random output=random_samples npoints=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
- </pre></div>
- Generate 20 random points and sample attribute data from geology (vector) map:
- <div class="code"><pre>
- g.region -p vector=geology
- v.random output=random_samples npoints=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
- </pre></div>
- Generate 20 random points in forested areas
- <div class="code"><pre>
- g.region -p raster=landclass96
- r.to.vect -v input=landclass96 output=landclass96 type=area
- v.random input=landclass96 output=random_samples npoints=20 \
- where="label = 'forest'"
- </pre></div>
- Generate 20 random points in each forest patch
- <div class="code"><pre>
- g.region -p raster=landclass96
- r.to.vect -v input=landclass96 output=landclass96 type=area
- v.random input=landclass96 output=random_samples npoints=20 \
- where="label = 'forest'" -a
- </pre></div>
- <h2>SEE ALSO</h2>
- <em>
- <a href="g.region.html">g.region</a>,
- <a href="r.random.html">r.random</a>,
- <a href="v.perturb.html">v.perturb</a>,
- <a href="v.sample.html">v.sample</a>,
- <a href="v.what.rast.html">v.what.rast</a>,
- <a href="v.what.vect.html">v.what.vect</a>
- </em>
- <h2>AUTHOR</h2>
- <a href="http://mccauley-usa.com/">James Darrell McCauley</a>
- <a href="mailto:darrell@mccauley-usa.com"><darrell@mccauley-usa.com></a>,
- <br>when he was at:
- <a href="http://ABE.www.ecn.purdue.edu/ABE/">Agricultural
- Engineering</a>
- <a href="http://www.purdue.edu/">Purdue University</a>
- <p><i>Last changed: $Date$</i>
|