Przeglądaj źródła

r.stream.extract: allow modified accumulation map

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@71695 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 7 lat temu
rodzic
commit
18a323fbbd

+ 13 - 5
raster/r.stream.extract/load.c

@@ -96,7 +96,20 @@ int load_maps(int ele_fd, int acc_fd)
 		}
 		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 @@ int load_maps(int ele_fd, int acc_fd)
 		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);

+ 1 - 3
raster/r.stream.extract/r.stream.extract.html

@@ -220,14 +220,12 @@ r.stream.extract elevation=elev_ned_30m@PERMANENT \
                  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@PERMANENT \
                  accumulation=elev_ned_30m.acc.weighed \
                  threshold=1000 \
                  stream_rast=elev_ned_30m.streams
-r.mask -r
 </pre></div>
 
 <p>