[GRASS-SVN] r71695 - grass/trunk/raster/r.stream.extract

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Nov 12 05:07:56 PST 2017


Author: mmetz
Date: 2017-11-12 05:07:55 -0800 (Sun, 12 Nov 2017)
New Revision: 71695

Modified:
   grass/trunk/raster/r.stream.extract/load.c
   grass/trunk/raster/r.stream.extract/r.stream.extract.html
Log:
r.stream.extract: allow modified accumulation map

Modified: grass/trunk/raster/r.stream.extract/load.c
===================================================================
--- grass/trunk/raster/r.stream.extract/load.c	2017-11-12 13:02:15 UTC (rev 71694)
+++ grass/trunk/raster/r.stream.extract/load.c	2017-11-12 13:07:55 UTC (rev 71695)
@@ -96,7 +96,20 @@
 		}
 		Rast_set_d_null_value(&acc_value, 1);
 	    }
+	    else if (acc_fd >= 0 && Rast_is_null_value(acc_ptr, acc_map_type)) {
+		/* elevation is not NULL, but provided accumulation is NULL
+		 * this is ok after weighing or 
+		 * when analysing a selected upstream catchment area */
+		FLAG_SET(afbuf[c].flag, NULLFLAG);
+		FLAG_SET(afbuf[c].flag, INLISTFLAG);
+		FLAG_SET(afbuf[c].flag, WORKEDFLAG);
+		FLAG_SET(afbuf[c].flag, WORKED2FLAG);
+		Rast_set_c_null_value(&ele_value, 1);
+		Rast_set_d_null_value(&acc_value, 1);
+	    }
 	    else {
+		/* elevation is not NULL, and 
+		 * if accumulation is provided it is also not NULL */
 		switch (ele_map_type) {
 		case CELL_TYPE:
 		    ele_value = *((CELL *) ptr);
@@ -115,11 +128,6 @@
 		if (acc_fd < 0)
 		    acc_value = 1;
 		else {
-		    if (Rast_is_null_value(acc_ptr, acc_map_type)) {
-			/* can this be ok after weighing ? */
-			G_fatal_error(_("Accumulation raster map is NULL but elevation map is not NULL"));
-		    }
-
 		    switch (acc_map_type) {
 		    case CELL_TYPE:
 			acc_value = *((CELL *) acc_ptr);

Modified: grass/trunk/raster/r.stream.extract/r.stream.extract.html
===================================================================
--- grass/trunk/raster/r.stream.extract/r.stream.extract.html	2017-11-12 13:02:15 UTC (rev 71694)
+++ grass/trunk/raster/r.stream.extract/r.stream.extract.html	2017-11-12 13:07:55 UTC (rev 71695)
@@ -220,14 +220,12 @@
                  stream_rast=elev_ned_30m.streams.noweight
 
 # extract streams from weighed map
-# requires a priori no-data filtering
-r.mapcalc "MASK = if(isnull(elev_ned_30m.acc.weighed), null(), 1)"
+# note that the weighed map is a bit smaller than the original map
 
 r.stream.extract elevation=elev_ned_30m at PERMANENT \
                  accumulation=elev_ned_30m.acc.weighed \
                  threshold=1000 \
                  stream_rast=elev_ned_30m.streams
-r.mask -r
 </pre></div>
 
 <p>



More information about the grass-commit mailing list