[GRASS-SVN] r66382 - grass/trunk/display/d.rast.arrow
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Sep 30 09:37:51 PDT 2015
Author: hcho
Date: 2015-09-30 09:37:51 -0700 (Wed, 30 Sep 2015)
New Revision: 66382
Modified:
grass/trunk/display/d.rast.arrow/d.rast.arrow.html
grass/trunk/display/d.rast.arrow/main.c
Log:
d.rast.arrow: Added the Drainage aspect type (r.watershed drainage= output)
Modified: grass/trunk/display/d.rast.arrow/d.rast.arrow.html
===================================================================
--- grass/trunk/display/d.rast.arrow/d.rast.arrow.html 2015-09-30 15:43:34 UTC (rev 66381)
+++ grass/trunk/display/d.rast.arrow/d.rast.arrow.html 2015-09-30 16:37:51 UTC (rev 66382)
@@ -25,9 +25,9 @@
You may adjust the overall scale using the <em>scale</em> option.
<em>d.rast.arrow</em> will ignore NULL and negative magnitudes, and will
warn you if the debug level is set at 5 or higher. Be aware. If your application
-uses negative values for magnitude, you can use <em>r.mapcalc</em> to prepare
-the magnitude map to suit your needs (absolute value, inverted direction and
-so on).
+uses negative values for magnitude, you can use
+<em><a href="r.mapcalc.html">r.mapcalc</a></em> to prepare the magnitude map to
+suit your needs (absolute value, inverted direction and so on).
<p><h2>NOTES</h2>
By default, arrows are drawn at the size of a cell and cannot be seen if
@@ -36,11 +36,14 @@
with relatively high resolutions. It may be useful to disable the grid in
this case, which is accomplished by setting its color to "<tt>none</tt>".
<p>For GRASS and Compass type aspect maps, the cell values of the aspect map
-will determine the corresponding direction in 360 degrees. ANSWERS type
-aspect maps will be plotted in multiples of 15 degrees, and AGNPS type
-aspect maps will be displayed in D8 representation, i.e. the eight multiples
-of 45 degrees.
-<p>GRASS aspect maps are measured using Cartesian conventions, i.e. in degrees
+will determine the corresponding direction in 360 degrees. ANSWERS type aspect
+maps will be plotted in multiples of 15 degrees counterclockwise from east, and
+AGNPS and Drainage type aspect maps will be displayed in D8 representation,
+i.e. the eight multiples of 45 degrees. Cell values are 1 to 8 clockwise from
+north for AGNPS and 1 to 8 counterclockwise from north east for Drainage. See
+<em><a href="r.watershed.html">r.watershed</a></em> for more details about the
+Drainage aspect.
+<p>GRASS aspect maps are measured using Cartesian conventions, i.e. in degrees
counterclockwise from east. e.g.:
<div class="code"><pre>
@@ -50,7 +53,8 @@
0,360 East
</pre></div>
-They can be created from a raster elevation map with <em>r.slope.aspect</em>.
+They can be created from a raster elevation map with
+<em><a href="r.slope.aspect.html">r.slope.aspect</a></em>.
<p>Compass type aspect maps are measured in degrees clockwise from north.
<p>This module uses oceanographic conventions, i.e. arrows point downslope or
direction "to", as opposed to atmospheric conventions (direction "from").
@@ -75,6 +79,7 @@
<em><a href="d.rast.num.html">d.rast.num</a></em><br>
<em><a href="g.region.html">g.region</a></em><br>
<em><a href="r.slope.aspect.html">r.slope.aspect</a></em><br>
+<em><a href="r.watershed.html">r.watershed</a></em><br>
<br>
<h2>AUTHORS</h2>
@@ -86,6 +91,8 @@
<u>Magnitude and 360 arrow code</u><br>
Hamish Bowman<br>
<em>Department of Marine Science, <br>
-University of Otago, New Zealand</em>
+University of Otago, New Zealand</em><br><br>
+<u>Align grids with raster cells and Drainage aspect type</u><br>
+Huidae Cho<br>
<p><i>Last changed: $Date$</i>
Modified: grass/trunk/display/d.rast.arrow/main.c
===================================================================
--- grass/trunk/display/d.rast.arrow/main.c 2015-09-30 15:43:34 UTC (rev 66381)
+++ grass/trunk/display/d.rast.arrow/main.c 2015-09-30 16:37:51 UTC (rev 66382)
@@ -15,6 +15,8 @@
/* some minor cleanup done by Andreas Lange, andreas.lange at rhein-main.de
* Update to handle NULLs and floating point aspect maps: Hamish Bowman, Aug 2004
* Update for 360 degree arrows and magnitude scaling: Hamish Bowman, Oct 2005
+ * Align grids with raster cells: Huidae Cho, Apr 2009
+ * Drainage aspect type: Huidae Cho, Sep 2015
*/
/*
@@ -107,7 +109,7 @@
opt2->type = TYPE_STRING;
opt2->required = NO;
opt2->answer = "grass";
- opt2->options = "grass,compass,agnps,answers";
+ opt2->options = "grass,compass,drainage,agnps,answers";
opt2->description = _("Type of existing raster aspect map");
opt3 = G_define_standard_option(G_OPT_C);
@@ -199,6 +201,8 @@
map_type = 3;
else if (strcmp("compass", opt2->answer) == 0)
map_type = 4;
+ else if (strcmp("drainage", opt2->answer) == 0)
+ map_type = 5;
scale = atof(opt8->answer);
@@ -373,7 +377,7 @@
/* treat AGNPS and ANSWERS data like old zero-as-null CELL */
/* TODO: update models */
- if (map_type == 2 || map_type == 3) {
+ if (map_type == 2 || map_type == 3 || map_type == 5) {
if (Rast_is_null_value(ptr, raster_type))
aspect_c = 0;
else
@@ -507,6 +511,53 @@
}
}
+ /* case switch for r.watershed drainage type aspect map */
+ else if (map_type == 5) {
+ D_use_color(arrow_color);
+ switch (aspect_c >= 0 ? aspect_c : -aspect_c) {
+ case 0:
+ /* only draw if x_color is not none (transparent) */
+ if (x_color > 0) {
+ D_use_color(x_color);
+ draw_x();
+ D_use_color(arrow_color);
+ }
+ break;
+ case 1:
+ arrow_ne();
+ break;
+ case 2:
+ arrow_n();
+ break;
+ case 3:
+ arrow_nw();
+ break;
+ case 4:
+ arrow_w();
+ break;
+ case 5:
+ arrow_sw();
+ break;
+ case 6:
+ arrow_s();
+ break;
+ case 7:
+ arrow_se();
+ break;
+ case 8:
+ arrow_e();
+ break;
+ default:
+ /* only draw if unknown_color is not none */
+ if (unknown_color > 0) {
+ D_use_color(unknown_color);
+ unknown_();
+ D_use_color(arrow_color);
+ }
+ break;
+ }
+ }
+
ptr = G_incr_void_ptr(ptr, Rast_cell_size(raster_type));
if (opt7->answer)
mag_ptr =
More information about the grass-commit
mailing list