[GRASS-SVN] r33886 - grass/trunk/raster/r.series

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Oct 15 11:14:42 EDT 2008


Author: glynn
Date: 2008-10-15 11:14:42 -0400 (Wed, 15 Oct 2008)
New Revision: 33886

Modified:
   grass/trunk/raster/r.series/main.c
   grass/trunk/raster/r.series/r.series.html
Log:
Add range= option


Modified: grass/trunk/raster/r.series/main.c
===================================================================
--- grass/trunk/raster/r.series/main.c	2008-10-15 15:10:56 UTC (rev 33885)
+++ grass/trunk/raster/r.series/main.c	2008-10-15 15:14:42 UTC (rev 33886)
@@ -104,7 +104,7 @@
     struct GModule *module;
     struct
     {
-	struct Option *input, *output, *method;
+	struct Option *input, *output, *method, *range;
     } parm;
     struct
     {
@@ -119,6 +119,7 @@
     DCELL *values, *values_tmp;
     int nrows, ncols;
     int row, col;
+    double lo, hi;
 
     G_gisinit(argv[0]);
 
@@ -142,6 +143,12 @@
     parm.method->description = _("Aggregate operation");
     parm.method->multiple = YES;
 
+    parm.range = G_define_option();
+    parm.range->key = "range";
+    parm.range->type = TYPE_DOUBLE;
+    parm.range->key_desc = "lo,hi";
+    parm.range->description = _("Ignore values outside this range");
+
     flag.nulls = G_define_flag();
     flag.nulls->key = 'n';
     flag.nulls->description = _("Propagate NULLs");
@@ -149,6 +156,11 @@
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
+    if (parm.range->answer) {
+	lo = atof(parm.range->answers[0]);
+	hi = atof(parm.range->answers[1]);
+    }
+
     /* process the input maps */
     for (i = 0; parm.input->answers[i]; i++)
 	;
@@ -222,6 +234,10 @@
 
 		if (G_is_d_null_value(&v))
 		    null = 1;
+		else if (parm.range->answer && (v < lo || v > hi)) {
+		    G_set_d_null_value(&v, 1);
+		    null = 1;
+		}
 
 		values[i] = v;
 	    }

Modified: grass/trunk/raster/r.series/r.series.html
===================================================================
--- grass/trunk/raster/r.series/r.series.html	2008-10-15 15:10:56 UTC (rev 33885)
+++ grass/trunk/raster/r.series/r.series.html	2008-10-15 15:14:42 UTC (rev 33886)
@@ -40,9 +40,10 @@
 number of the raster map that holds the minimum/maximum value of the
 time-series. The numbering starts at <em>0</em> up to <em>n</em> for the
 first and the last raster listed in <em>input=</em>, respectively. 
+<p>
+If the <em>range=</em> option is given, any values which fall outside
+that range will be treated as if they were NULL.
 
-
-
 <h2>EXAMPLES</h2>
 
 Using <em>r.series</em> with wildcards:



More information about the grass-commit mailing list