[GRASS-SVN] r35641 - in grass/trunk/raster/r.watershed: front ram seg

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jan 26 05:37:09 EST 2009


Author: mmetz
Date: 2009-01-26 05:37:08 -0500 (Mon, 26 Jan 2009)
New Revision: 35641

Modified:
   grass/trunk/raster/r.watershed/front/r.watershed.html
   grass/trunk/raster/r.watershed/ram/do_cum.c
   grass/trunk/raster/r.watershed/seg/do_cum.c
Log:
Updated documentation. MFD: edge artifacts removed.

Modified: grass/trunk/raster/r.watershed/front/r.watershed.html
===================================================================
--- grass/trunk/raster/r.watershed/front/r.watershed.html	2009-01-26 08:07:13 UTC (rev 35640)
+++ grass/trunk/raster/r.watershed/front/r.watershed.html	2009-01-26 10:37:08 UTC (rev 35641)
@@ -93,7 +93,7 @@
 <dd>The minimum size of an exterior watershed basin in cells, if no flow
 map is input, or overland flow units when a flow map is given.
 Warning: low threshold values will dramactically increase run time and
-generate difficult too read basin and half_basin results.
+generate difficult to read basin and half_basin results.
 This parameter also controls the level of detail in the <em>stream</em>
 segments map.
 
@@ -120,10 +120,10 @@
 <dt><em>drainage</em> 
 
 <dd>Output map: drainage direction.  Provides the "aspect" for each
-cell.  Multiplying positive values by 45 will give the direction in
-degrees that the surface runoff will travel from that cell.  The
-value 0 (zero) indicates that the cell is a depression area (defined by
-the depression input map).  Negative values indicate that
+cell measured CCW from East.  Multiplying positive values by 45 will give 
+the direction in degrees that the surface runoff will travel from that 
+cell.  The value 0 (zero) indicates that the cell is a depression area 
+(defined by the depression input map).  Negative values indicate that
 surface runoff is leaving the boundaries of the current geographic
 region.  The absolute value of these negative cells indicates the
 direction of flow.
@@ -139,7 +139,8 @@
 <dt><em>stream</em> 
 
 <dd>Output map: stream segments.  Values correspond to the watershed
-basin values.
+basin values.  Can be vectorized after thinning (<em>r.thin</em>) with 
+<em>r.to.vect</em>.
 
 <dt><em>half_basin</em> 
 
@@ -297,7 +298,7 @@
 percentage of the overall area.
 <p>
 Gaps (NULL cells) in the elevation map that are located within the area 
-of interest will heavily influence flow accumulation: water will 
+of interest will heavily influence the analysis: water will 
 flow into but not out of these gaps. These gaps must be filled beforehand, 
 e.g. with <em>r.fillnulls</em>.
 <p>
@@ -321,8 +322,16 @@
 <p>
 To create <i>river mile</i> segmentation from a vectorized streams map,
 try the <em>v.net.iso</em> or <em>v.lrs.segment</em> modules.
+<p>
+The stream segments output can be easily vectorized after thinning with 
+<em>r.thin</em>. Each stream segment in the vector map will have the 
+value of the associated basin. To isolate subbasins and streams for a 
+larger basin, a MASK for the larger basin can be created with 
+<em>r.water.outlet</em>. The stream segments output serves as a guide 
+where to place the outlet point used as input to <em>r.water.outlet</em>. 
+The basin threshold must have been sufficiently small to isolate a 
+stream network and subbasins within the larger basin.
 
-
 <h2>EXAMPLES</h2>
 <i>These examples use the Spearfish sample dataset.</i>
 <p>

Modified: grass/trunk/raster/r.watershed/ram/do_cum.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/do_cum.c	2009-01-26 08:07:13 UTC (rev 35640)
+++ grass/trunk/raster/r.watershed/ram/do_cum.c	2009-01-26 10:37:08 UTC (rev 35641)
@@ -101,8 +101,6 @@
     CELL is_swale;
     DCELL value, valued;
     int killer, threshold, count;
-    SHORT asp_r[9] = { 0, -1, -1, -1, 0, 1, 1, 1, 0 };
-    SHORT asp_c[9] = { 0, 1, 0, -1, -1, -1, 0, 1, 1 };
 
     /* MFD */
     int mfd_cells, stream_cells, swale_cells, astar_not_set, is_null;
@@ -111,7 +109,9 @@
     double dx, dy;
     CELL ele, ele_nbr, aspect, is_worked;
     double prop, max_acc;
-    int workedon;
+    int workedon, edge;
+    SHORT asp_r[9] = { 0, -1, -1, -1, 0, 1, 1, 1, 0 };
+    SHORT asp_c[9] = { 0, 1, 0, -1, -1, -1, 0, 1, 1 };
 
     G_message(_("SECTION 3: Accumulating Surface Flow with MFD."));
     G_debug(1, "MFD convergence factor set to %d.", c_fac);
@@ -172,6 +172,7 @@
 	    astar_not_set = 1;
 	    ele = alt[SEG_INDEX(alt_seg, r, c)];
 	    is_null = 0;
+	    edge = 0;
 	    /* this loop is needed to get the sum of weights */
 	    for (ct_dir = 0; ct_dir < sides; ct_dir++) {
 		/* get r, c (r_nbr, c_nbr) for neighbours */
@@ -194,6 +195,7 @@
 		    if (is_worked == 0) {
 			ele_nbr = alt[SEG_INDEX(alt_seg, r_nbr, c_nbr)];
 			is_null = G_is_c_null_value(&ele_nbr);
+			edge = is_null;
 			if (!is_null && ele_nbr <= ele) {
 			    if (ele_nbr < ele) {
 				weight[ct_dir] =
@@ -221,7 +223,20 @@
 		    if (dr == r_nbr && dc == c_nbr)
 			np_side = ct_dir;
 		}
+		else
+		    edge = 1;
+		if (edge)
+		    break;
 	    }
+	    /* do not distribute flow along edges, this causes artifacts */
+	    if (edge) {
+		is_swale = FLAG_GET(swale, r, c);
+		if (is_swale && aspect > 0) {
+		    aspect = -1 * drain[r - r_nbr + 1][c - c_nbr + 1];
+		    asp[SEG_INDEX(asp_seg, r, c)] = aspect;
+		}
+		continue;
+	    }
 
 	    /* honour A * path 
 	     * mfd_cells == 0: fine, SFD along A * path

Modified: grass/trunk/raster/r.watershed/seg/do_cum.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/do_cum.c	2009-01-26 08:07:13 UTC (rev 35640)
+++ grass/trunk/raster/r.watershed/seg/do_cum.c	2009-01-26 10:37:08 UTC (rev 35641)
@@ -114,7 +114,7 @@
     double dx, dy;
     CELL ele, ele_nbr, asp_val, asp_val2, cvalue, *worked_nbr;
     double prop, max_acc;
-    int workedon;
+    int workedon, edge;
     SHORT asp_r[9] = { 0, -1, -1, -1, 0, 1, 1, 1, 0 };
     SHORT asp_c[9] = { 0, 1, 0, -1, -1, -1, 0, 1, 1 };
 
@@ -187,6 +187,7 @@
 	    astar_not_set = 1;
 	    cseg_get(&alt, &ele, r, c);
 	    is_null = 0;
+	    edge = 0;
 	    /* this loop is needed to get the sum of weights */
 	    for (ct_dir = 0; ct_dir < sides; ct_dir++) {
 		/* get r, c (r_nbr, c_nbr) for neighbours */
@@ -211,6 +212,7 @@
 		    if (worked_nbr[ct_dir] == 0) {
 			cseg_get(&alt, &ele_nbr, r_nbr, c_nbr);
 			is_null = G_is_c_null_value(&ele_nbr);
+			edge = is_null;
 			if (!is_null && ele_nbr <= ele) {
 			    if (ele_nbr < ele) {
 				weight[ct_dir] =
@@ -238,7 +240,20 @@
 		    if (dr == r_nbr && dc == c_nbr)
 			np_side = ct_dir;
 		}
+		else
+		    edge = 1;
+		if (edge)
+		    break;
 	    }
+	    /* do not distribute flow along edges, this causes artifacts */
+	    if (edge) {
+		bseg_get(&swale, &is_swale, r, c);
+		if (is_swale && asp_val > 0) {
+		    asp_val = -1 * drain[r - r_nbr + 1][c - c_nbr + 1];
+		    cseg_put(&asp, &asp_val, r, c);
+		}
+		continue;
+	    }
 
 	    /* honour A * path 
 	     * mfd_cells == 0: fine, SFD along A * path



More information about the grass-commit mailing list