r.random.cells.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <h2>DESCRIPTION</h2>
  2. <em>r.random.cells</em> generates a random sets of raster cells that are
  3. at least <b>distance</b> apart. The cells are numbered from 1 to the
  4. numbers of cells generated, all other cells are NULL (no data). Random
  5. cells will not be generated in areas masked off.
  6. <h3>Detailed parameter description</h3>
  7. <dl>
  8. <dt><b>output</b></dt>
  9. <dd>Random cells. Each random cell has a unique non-zero cell value
  10. ranging from 1 to the number of cells generated. The heuristic for
  11. this algorithm is to randomly pick cells until there are no cells
  12. outside of the chosen cell's buffer of radius <b>distance</b>.</dd>
  13. <dt><b>distance</b></dt>
  14. <dd>Determines the minimum distance the centers of the random cells
  15. will be apart.</dd>
  16. <dt><b>seed</b></dt>
  17. <dd>Specifies the random seed that
  18. <em>r.random.cells</em> will use to generate the cells. If the random seed
  19. is not given,<em> r.random.cells</em> will get a seed from the process ID
  20. number.</dd>
  21. </dl>
  22. <h2>NOTES</h2>
  23. The original purpose for this program was to generate independent
  24. random samples of cells in a study area. The <b>distance</b> value is
  25. the amount of spatial autocorrelation for the map being studied.
  26. <!-- The amount of spatial autocorrelation can be determined by
  27. using <em>r.2Dcorrelogram</em> with
  28. <em>r.2Dto1D</em>, or <em>r.1Dcorrelogram</em>. With <b>distance</b> set to
  29. zero, the <b>output</b> map will number each non-masked cell from 1 to the
  30. number of non-masked cells in the study region. -->
  31. <h2>EXAMPLE</h2>
  32. <h3>Random cells in given distances</h3>
  33. North Carolina sample dataset example:
  34. <div class="code"><pre>
  35. g.region n=228500 s=215000 w=630000 e=645000 res=100 -p
  36. r.random.cells output=random_500m distance=500
  37. </pre></div>
  38. <h3>Limited number of random points</h3>
  39. Here is another example where we will create given number of vector points
  40. with the given minimal distances.
  41. Let's star with setting the region (we use large cells here):
  42. <div class="code"><pre>
  43. g.region raster=elevation
  44. g.region rows=20 cols=20 -p
  45. </pre></div>
  46. Then we generate random cells and we limit their count to 20:
  47. <div class="code"><pre>
  48. r.random.cells output=random_cells distance=1500 ncells=20 seed=200
  49. </pre></div>
  50. Finally, we convert the raster cells to points using
  51. <em><a href="r.to.vect.html">r.to.vect</a></em> module:
  52. <div class="code"><pre>
  53. r.to.vect input=random_cells output=random_points type=point
  54. </pre></div>
  55. An example of the result is at the Figure below on the left
  56. in comparison with the result without the cell limit on the right.
  57. <p>
  58. Additionally, we can use <em><a href="v.perturb.html">v.perturb</a></em> module
  59. to add random spatial deviation to their position so that they are not
  60. perfectly aligned with the grid. We cannot perturb the points too much,
  61. otherwise we might seriously break the minimal distance we set earlier.
  62. <div class="code"><pre>
  63. v.perturb input=random_points output=random_points_moved parameters=50 seed=200
  64. </pre></div>
  65. In the above examples, we were using fixed seed. This is advantageous when
  66. we want to generate (pseudo) random data, but we want to get reproducible
  67. results at the same time.
  68. <center>
  69. <img src="r_random_cells.png" alt="Cells and points filling the space">
  70. <p><em>
  71. Figure: Generated cells with limited number of cells (upper left),
  72. derived vector points (lower left), cells without a count limit
  73. (upper right) and corresponding vector points (lower right)
  74. </em></p>
  75. </center>
  76. <!--
  77. r.random.cells output=random_cells_all distance=1500 seed=200
  78. r.random.cells output=random_cells distance=1500 ncells=20 seed=200
  79. r.to.vect input=random_cells_all output=random_points_all type=point
  80. r.to.vect input=random_cells output=random_points type=point
  81. d.mon cairo out=r_random_cells.png
  82. d.frame frame=a at=50,100,0,50 -c
  83. d.rast random_cells
  84. d.frame frame=b at=50,100,50,100 -c
  85. d.rast random_cells_all
  86. d.frame frame=c at=0,50,0,50 -c
  87. d.vect random_points color=0:53:106 fill_color=30:144:255 width=1 icon=basic/point size=20
  88. d.frame frame=d at=0,50,50,100 -c
  89. d.vect random_points_all color=0:53:106 fill_color=30:144:255 width=1 icon=basic/point size=20
  90. d.mon stop=cairo
  91. mogrify -trim r_random_cells.png
  92. -->
  93. <h2>REFERENCES</h2>
  94. Random Field Software for GRASS GIS by Chuck Ehlschlaeger
  95. <p> As part of my dissertation, I put together several programs that help
  96. GRASS (4.1 and beyond) develop uncertainty models of spatial data. I hope
  97. you find it useful and dependable. The following papers might clarify their
  98. use:
  99. <ul>
  100. <li> Ehlschlaeger, C.R., Shortridge, A.M., Goodchild, M.F., 1997.
  101. Visualizing spatial data uncertainty using animation.
  102. Computers &amp; Geosciences 23, 387-395. doi:10.1016/S0098-3004(97)00005-8</li>
  103. <li><a href="http://www.geo.hunter.cuny.edu/~chuck/paper.html">Modeling
  104. Uncertainty in Elevation Data for Geographical Analysis</a>, by
  105. Charles R. Ehlschlaeger, and Ashton M. Shortridge. Proceedings of the
  106. 7th International Symposium on Spatial Data Handling, Delft,
  107. Netherlands, August 1996.</li>
  108. <li><a href="http://www.geo.hunter.cuny.edu/~chuck/acm/paper.html">Dealing
  109. with Uncertainty in Categorical Coverage Maps: Defining, Visualizing,
  110. and Managing Data Errors</a>, by Charles Ehlschlaeger and Michael
  111. Goodchild. Proceedings, Workshop on Geographic Information Systems at
  112. the Conference on Information and Knowledge Management, Gaithersburg
  113. MD, 1994.</li>
  114. <li><a href="http://www.geo.hunter.cuny.edu/~chuck/gislis/gislis.html">Uncertainty
  115. in Spatial Data: Defining, Visualizing, and Managing Data
  116. Errors</a>, by Charles Ehlschlaeger and Michael
  117. Goodchild. Proceedings, GIS/LIS'94, pp. 246-253, Phoenix AZ,
  118. 1994.</li>
  119. </ul>
  120. <h2>SEE ALSO</h2>
  121. <em>
  122. <!--r.1Dcorrelogram,
  123. r.2Dcorrelogram,
  124. r.2Dto1D, -->
  125. <a href="r.random.surface.html">r.random.surface</a>,
  126. <a href="r.random.html">r.random</a>,
  127. <a href="v.random.html">v.random</a>,
  128. <a href="r.to.vect.html">r.to.vect</a>,
  129. <a href="v.perturb.html">v.perturb</a>
  130. </em>
  131. <h2>AUTHOR</h2>
  132. Charles Ehlschlaeger; National Center for Geographic Information and
  133. Analysis, University of California, Santa Barbara.
  134. <p><i>Last changed: $Date$</i>