v.random.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <h2>DESCRIPTION</h2>
  2. <em>v.random</em> randomly generates vector points within the
  3. current region using the selected random number generator.
  4. <p><em>v.random</em> can generate also 3D vector points or
  5. write random value to attribute table. Point height range or
  6. attribute value range is controlled by specifying zmin and zmax values.
  7. Both z values are included in range (<em>zmin &lt;= z &lt;= zmax</em>).
  8. Generated random attribute value type can be controlled by column
  9. data type. Use <b>INTEGER</b> column type for integers and
  10. <b>DOUBLE PRECISION</b> for floating point numbers. Integer values are
  11. calculated by rounding random floating point number.
  12. <p>To produce repeatable results a random seed can be set using the
  13. option <em>seed</em>.
  14. <h3>Restriction to vector areas</h3>
  15. <p>
  16. If an <em>input</em> vector map with areas is specified, the location of
  17. random points is restricted to the selected areas. By default, the
  18. requested number of points are distributed across all areas.
  19. <p>
  20. If the <em>-a</em> flag is given, the requested number of points is
  21. generated for each individual area. For example, if 20 points should be
  22. generated and the input map has 100 individual areas, 2000 points will
  23. be generated in total.
  24. <h2>EXAMPLES</h2>
  25. All examples use the North Carolina sample dataset.
  26. <p>
  27. Generate 20 random points with binary attribute (only 0 or 1):
  28. <div class="code"><pre>
  29. v.random output=binary_random npoints=20 zmin=0 zmax=1 column='binary INTEGER'
  30. </pre></div>
  31. Generate 20 random 3D points using a specific random seed:
  32. <div class="code"><pre>
  33. v.random seed=52 output=height_random npoints=40 zmin=110 zmax=170 -z
  34. </pre></div>
  35. <p>
  36. <center>
  37. <img src="vrandom_z.png"><br>
  38. Random points with different X, Y, and Z coordinates
  39. </center>
  40. <!--
  41. g.region rast=elev_lid792_1m
  42. ...
  43. d.vect height_random color=60:60:60 icon=basic/point size=40 width=2 zcolor=gyr
  44. optipng -o5 map.png
  45. mv map.png vrandom_z.png
  46. -->
  47. Get 20 random samples from raster map:
  48. <div class="code"><pre>
  49. g.region -p raster=elevation
  50. v.random output=random_samples npoints=20
  51. v.db.addtable map=random_samples layer=1 columns='cat INTEGER, sample DOUBLE PRECISION'
  52. v.what.rast vector=random_samples raster=elevation@PERMANENT layer=1 column=sample
  53. </pre></div>
  54. Generate 20 random points and sample attribute data from geology (vector) map:
  55. <div class="code"><pre>
  56. g.region -p vector=geology
  57. v.random output=random_samples npoints=20
  58. v.db.addtable map=random_samples layer=1 columns='cat integer, geology varchar(100)'
  59. v.what.vect vector=random_samples layer=1 column=geology \
  60. qvector=geology@PERMANENT qlayer=1 qcolumn=label
  61. </pre></div>
  62. Generate 20 random points in forested areas
  63. <div class="code"><pre>
  64. g.region -p raster=landclass96
  65. r.to.vect -v input=landclass96 output=landclass96 type=area
  66. v.random input=landclass96 output=random_samples npoints=20 \
  67. where="label = 'forest'"
  68. </pre></div>
  69. Generate 20 random points in each forest patch
  70. <div class="code"><pre>
  71. g.region -p raster=landclass96
  72. r.to.vect -v input=landclass96 output=landclass96 type=area
  73. v.random input=landclass96 output=random_samples npoints=20 \
  74. where="label = 'forest'" -a
  75. </pre></div>
  76. <h2>SEE ALSO</h2>
  77. <em>
  78. <a href="g.region.html">g.region</a>,
  79. <a href="r.random.html">r.random</a>,
  80. <a href="v.perturb.html">v.perturb</a>,
  81. <a href="v.sample.html">v.sample</a>,
  82. <a href="v.what.rast.html">v.what.rast</a>,
  83. <a href="v.what.vect.html">v.what.vect</a>
  84. </em>
  85. <h2>AUTHOR</h2>
  86. <a href="http://mccauley-usa.com/">James Darrell McCauley</a>
  87. <a href="mailto:darrell@mccauley-usa.com">&lt;darrell@mccauley-usa.com&gt;</a>,
  88. <br>when he was at:
  89. <a href="http://ABE.www.ecn.purdue.edu/ABE/">Agricultural
  90. Engineering</a>
  91. <a href="http://www.purdue.edu/">Purdue University</a>
  92. <p><i>Last changed: $Date$</i>