Browse Source

Add range= option

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@33886 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 16 years ago
parent
commit
eddce94617
2 changed files with 20 additions and 3 deletions
  1. 17 1
      raster/r.series/main.c
  2. 3 2
      raster/r.series/r.series.html

+ 17 - 1
raster/r.series/main.c

@@ -104,7 +104,7 @@ int main(int argc, char *argv[])
     struct GModule *module;
     struct
     {
-	struct Option *input, *output, *method;
+	struct Option *input, *output, *method, *range;
     } parm;
     struct
     {
@@ -119,6 +119,7 @@ int main(int argc, char *argv[])
     DCELL *values, *values_tmp;
     int nrows, ncols;
     int row, col;
+    double lo, hi;
 
     G_gisinit(argv[0]);
 
@@ -142,6 +143,12 @@ int main(int argc, char *argv[])
     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 @@ int main(int argc, char *argv[])
     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 @@ int main(int argc, char *argv[])
 
 		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;
 	    }

+ 3 - 2
raster/r.series/r.series.html

@@ -40,8 +40,9 @@ The <em>min_raster</em> and <em>max_raster</em> methods generate a map with the
 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>