[GRASS-SVN] r33888 - in grass/trunk: include lib/stats raster/r.resamp.stats

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


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

Modified:
   grass/trunk/include/stats.h
   grass/trunk/lib/stats/c_max.c
   grass/trunk/lib/stats/c_min.c
   grass/trunk/raster/r.resamp.stats/main.c
   grass/trunk/raster/r.resamp.stats/r.resamp.stats.html
Log:
Add "weighted" versions of min, max aggregates
 (the actual weights are ignored; this just provides the stat_func_w
 interface for compatibility)
Change r.resamp.stats to use w_{min,max}.



Modified: grass/trunk/include/stats.h
===================================================================
--- grass/trunk/include/stats.h	2008-10-15 15:24:35 UTC (rev 33887)
+++ grass/trunk/include/stats.h	2008-10-15 15:32:42 UTC (rev 33888)
@@ -33,6 +33,8 @@
 extern stat_func_w w_ave;
 extern stat_func_w w_count;
 extern stat_func_w w_median;
+extern stat_func_w w_min;
+extern stat_func_w w_max;
 extern stat_func_w w_mode;
 extern stat_func_w w_quart1;
 extern stat_func_w w_quart3;

Modified: grass/trunk/lib/stats/c_max.c
===================================================================
--- grass/trunk/lib/stats/c_max.c	2008-10-15 15:24:35 UTC (rev 33887)
+++ grass/trunk/lib/stats/c_max.c	2008-10-15 15:32:42 UTC (rev 33888)
@@ -20,3 +20,24 @@
     else
 	*result = max;
 }
+
+void w_max(DCELL * result, DCELL(*values)[2], int n)
+{
+    DCELL max;
+    int i;
+
+    G_set_d_null_value(&max, 1);
+
+    for (i = 0; i < n; i++) {
+	if (G_is_d_null_value(&values[i][0]))
+	    continue;
+
+	if (G_is_d_null_value(&max) || max < values[i][0])
+	    max = values[i][0];
+    }
+
+    if (G_is_d_null_value(&max))
+	G_set_d_null_value(result, 1);
+    else
+	*result = max;
+}

Modified: grass/trunk/lib/stats/c_min.c
===================================================================
--- grass/trunk/lib/stats/c_min.c	2008-10-15 15:24:35 UTC (rev 33887)
+++ grass/trunk/lib/stats/c_min.c	2008-10-15 15:32:42 UTC (rev 33888)
@@ -20,3 +20,24 @@
     else
 	*result = min;
 }
+
+void w_min(DCELL * result, DCELL(*values)[2], int n)
+{
+    DCELL min;
+    int i;
+
+    G_set_d_null_value(&min, 1);
+
+    for (i = 0; i < n; i++) {
+	if (G_is_d_null_value(&values[i][0]))
+	    continue;
+
+	if (G_is_d_null_value(&min) || min > values[i][0])
+	    min = values[i][0];
+    }
+
+    if (G_is_d_null_value(&min))
+	G_set_d_null_value(result, 1);
+    else
+	*result = min;
+}

Modified: grass/trunk/raster/r.resamp.stats/main.c
===================================================================
--- grass/trunk/raster/r.resamp.stats/main.c	2008-10-15 15:24:35 UTC (rev 33887)
+++ grass/trunk/raster/r.resamp.stats/main.c	2008-10-15 15:32:42 UTC (rev 33888)
@@ -30,8 +30,8 @@
     {c_ave,    w_ave,    "average",  "average (mean) value"},
     {c_median, w_median, "median",   "median value"},
     {c_mode,   w_mode,   "mode",     "most frequently occuring value"},
-    {c_min,    NULL,     "minimum",  "lowest value"},
-    {c_max,    NULL,     "maximum",  "highest value"},
+    {c_min,    w_min,    "minimum",  "lowest value"},
+    {c_max,    w_max,    "maximum",  "highest value"},
     {c_quart1, w_quart1, "quart1",   "first quartile"},
     {c_quart3, w_quart3, "quart3",   "third quartile"},
     {c_perc90, w_perc90, "perc90",   "ninetieth percentile"},

Modified: grass/trunk/raster/r.resamp.stats/r.resamp.stats.html
===================================================================
--- grass/trunk/raster/r.resamp.stats/r.resamp.stats.html	2008-10-15 15:24:35 UTC (rev 33887)
+++ grass/trunk/raster/r.resamp.stats/r.resamp.stats.html	2008-10-15 15:32:42 UTC (rev 33888)
@@ -23,8 +23,13 @@
 Resampling modules (<em>r.resample, r.resamp.stats, r.resamp.interp,
 r.resamp.rst</em>) resample the map to match the current region settings.
 </p>
+<p>
+The notion of weighting doesn't make any sense for the min and max
+aggregates. However, the <em>-w</em> flag still has significance in
+that, when multiple destination cells overlap a source cell, the
+source cell is included in the calculation of all of the destination
+cells.
 
-
 <h2>SEE ALSO</h2>
 
 <em><a href="g.region.html">g.region</a></em>,



More information about the grass-commit mailing list