r.grow.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <h2>DESCRIPTION</h2>
  2. <em>r.grow</em> adds cells around the perimeters of all areas
  3. in a user-specified raster map layer and stores the output in
  4. a new raster map layer. The user can use it to grow by one or
  5. more than one cell (by varying the size of the <b>radius</b>
  6. parameter), or like <em>r.buffer</em>, but with the
  7. option of preserving the original cells (similar to combining
  8. <em>r.buffer</em> and <em>r.patch</em>).
  9. <h2>NOTES</h2>
  10. The user has the option of specifying three different metrics which
  11. control the geometry in which grown cells are created, (controlled by
  12. the <b>metric</b> parameter): <i>Euclidean</i>, <i>Manhattan</i>, and
  13. <i>Maximum</i>.
  14. <p>
  15. The <i>Euclidean distance</i> or <i>Euclidean metric</i> is the "ordinary" distance
  16. between two points that one would measure with a ruler, which can be
  17. proven by repeated application of the Pythagorean theorem.
  18. The formula is given by:
  19. <div class="code"><pre>d(dx,dy) = sqrt(dx^2 + dy^2)</pre></div>
  20. Cells grown using this metric would form isolines of distance that are
  21. circular from a given point, with the distance given by the <b>radius</b>.
  22. <p>
  23. The <i>Manhattan metric</i>, or <i>Taxicab geometry</i>, is a form of geometry in
  24. which the usual metric of Euclidean geometry is replaced by a new
  25. metric in which the distance between two points is the sum of the (absolute)
  26. differences of their coordinates. The name alludes to the grid layout of
  27. most streets on the island of Manhattan, which causes the shortest path a
  28. car could take between two points in the city to have length equal to the
  29. points' distance in taxicab geometry.
  30. The formula is given by:
  31. <div class="code"><pre>d(dx,dy) = abs(dx) + abs(dy)</pre></div>
  32. where cells grown using this metric would form isolines of distance that are
  33. rhombus-shaped from a given point.
  34. <p>
  35. The <i>Maximum metric</i> is given by the formula
  36. <div class="code"><pre>d(dx,dy) = max(abs(dx),abs(dy))</pre></div>
  37. where the isolines of distance from a point are squares.
  38. <p>
  39. If there are two cells which are equal candidates to grow into an empty space,
  40. <em>r.grow</em> will choose the northernmost candidate; if there are multiple
  41. candidates with the same northing, the westernmost is chosen.
  42. <h2>EXAMPLE</h2>
  43. You can shrink inwards by preparing an inverse map first, and then
  44. inverting the resulting grown map. For example:
  45. <div class="code"><pre>
  46. # Spearfish sample dataset
  47. MAP=fields
  48. g.region rast=$MAP
  49. r.mapcalc "inverse = if(isnull($MAP), 1, null())"
  50. r.grow in=inverse out=inverse.grown
  51. r.mapcalc "$MAP.shrunken = if(isnull(inverse.grown), $MAP, null())"
  52. r.colors $MAP.shrunken rast=$MAP
  53. g.remove inverse,inverse.grown
  54. </pre></div>
  55. <h2>SEE ALSO</h2>
  56. <em>
  57. <a href="r.buffer.html">r.buffer</a>,
  58. <a href="r.grow.distance.html">r.grow.distance</a>
  59. </em>
  60. <p>
  61. <em>
  62. <a href="r.distance.html">r.distance</a>,
  63. <a href="r.patch.html">r.patch</a>
  64. </em>
  65. <p>
  66. <em><a href="http://en.wikipedia.org/wiki/Euclidean_metric">Wikipedia Entry: Euclidean Metric</a></em><br>
  67. <em><a href="http://en.wikipedia.org/wiki/Manhattan_metric">Wikipedia Entry: Manhattan Metric</a></em>
  68. <h2>AUTHORS</h2>
  69. Marjorie Larson,
  70. U.S. Army Construction Engineering Research Laboratory
  71. <p>
  72. Glynn Clements
  73. <p>
  74. <i>Last changed: $Date$</i>