[GRASS-SVN] r29865 - grass/trunk/scripts/r.regression.line

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jan 27 16:32:29 EST 2008


Author: neteler
Date: 2008-01-27 16:32:29 -0500 (Sun, 27 Jan 2008)
New Revision: 29865

Modified:
   grass/trunk/scripts/r.regression.line/description.html
   grass/trunk/scripts/r.regression.line/r.regression.line
Log:
Slower but accurate calculation option

Modified: grass/trunk/scripts/r.regression.line/description.html
===================================================================
--- grass/trunk/scripts/r.regression.line/description.html	2008-01-27 18:03:18 UTC (rev 29864)
+++ grass/trunk/scripts/r.regression.line/description.html	2008-01-27 21:32:29 UTC (rev 29865)
@@ -8,8 +8,12 @@
 number of elements (N), means (medX, medY), standard deviations
 (sdX, sdY), and the F test for testing the significance of the
 regression model as a whole (F).
-<br>
 
+<H2>NOTES</H2>
+The flag <em>-s</em> select the slower method which writes out all
+pixel values individually to the temporary file. The result is then
+identical to that obtained from R-stats's lm() function. 
+
 <H2>EXAMPLE</H2>
 
 Comparison of the old and the new DEM in Spearfish:

Modified: grass/trunk/scripts/r.regression.line/r.regression.line
===================================================================
--- grass/trunk/scripts/r.regression.line/r.regression.line	2008-01-27 18:03:18 UTC (rev 29864)
+++ grass/trunk/scripts/r.regression.line/r.regression.line	2008-01-27 21:32:29 UTC (rev 29865)
@@ -23,6 +23,10 @@
 #%  key: g
 #%  description: Print in shell script style
 #%End
+#%flag
+#%  key: s
+#%  description: Slower but accurate
+#%End
 #%option
 #% key: map1
 #% type: string
@@ -90,7 +94,14 @@
 
 
 #calculate regression equation
-r.stats -cnA input=$GIS_OPT_MAP1,$GIS_OPT_MAP2  > "$TMP"
+if [ $GIS_FLAG_S -eq 1 ] ; then
+   # slower but accurate
+   r.stats -n1  input=$GIS_OPT_MAP1,$GIS_OPT_MAP2 | sed 's+$+ 1+g' > "$TMP"
+else
+   # count "identical" pixels
+   r.stats -cnA input=$GIS_OPT_MAP1,$GIS_OPT_MAP2  > "$TMP"
+fi
+
 if [ ! -s "$TMP" ] ; then
     g.message -e "One or both input maps only contain no data (NULL) pixels in the current region"
     exit 1



More information about the grass-commit mailing list