[GRASS-CVS] markus: grass6/scripts/r.regression.line description.html, 1.2, 1.3 r.regression.line, 1.15, 1.16

grass at intevation.de grass at intevation.de
Sun Dec 2 09:26:14 EST 2007


Author: markus

Update of /grassrepository/grass6/scripts/r.regression.line
In directory doto:/tmp/cvs-serv11573

Modified Files:
	description.html r.regression.line 
Log Message:
script style output added

Index: description.html
===================================================================
RCS file: /grassrepository/grass6/scripts/r.regression.line/description.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- description.html	30 Aug 2005 14:57:07 -0000	1.2
+++ description.html	2 Dec 2007 14:26:12 -0000	1.3
@@ -8,14 +8,32 @@
 <H2>EXAMPLE</H2>
 
 Comparison of the old and the new DEM in Spearfish:
-<PRE>
-g.region rast=elevation.10m
-r.regression.line elevation.dem map2=elevation.10m
-</PRE>
+<div class="code"><pre>
+g.region rast=elevation.10m -p
+r.regression.line map1=elevation.dem map2=elevation.10m
+</pre></div>
+<p>
+
+Using the script style flag AND <em>eval</em> to make results
+available in the shell:
+<div class="code"><pre>
+g.region rast=elevation.10m -p
+eval `r.regression.line -g map1=elevation.dem map2=elevation.10m`
+echo $a
+479.615
+
+echo $b
+0.645631
+
+echo $R
+0.804441
+</pre></div>
+
 
 <H2>AUTHOR</H2>
 
-Dr. Agustin Lobo - alobo at ija.csic.es<BR>
-Updated to GRASS 5.7 Michael Barton, Arizona State University
+Dr. Agustin Lobo - alobo at ija.csic.es<BR>
+Updated to GRASS 5.7 Michael Barton, Arizona State University<BR>
+Script style output Markus Neteler
 
 <p><i>Last changed: $Date$</i>

Index: r.regression.line
===================================================================
RCS file: /grassrepository/grass6/scripts/r.regression.line/r.regression.line,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- r.regression.line	29 Mar 2007 09:34:39 -0000	1.15
+++ r.regression.line	2 Dec 2007 14:26:12 -0000	1.16
@@ -19,6 +19,10 @@
 #%  description: Calculates linear regression from two raster maps: y = a + b*x
 #%  keywords: raster, statistics
 #%End
+#%flag
+#%  key: g
+#%  description: Print in shell script style
+#%End
 #%option
 #% key: map1
 #% type: string
@@ -81,32 +85,42 @@
 mediaY=sumY/tot;sumsqY=sumsqY/tot;varY=sumsqY-(mediaY^2);sdY=varY^0.5;\
 A=mediaY - B*mediaX; F= R^2/(1-R^2/tot-2);\
 print A, B, R, tot, F, mediaX, sdX, mediaY, sdY}' "$TMP" > "$TMP"b
-#cat "$TMP"b
+
+echo "a b R N F medX sdX medY sdY" | tr -s ' ' '\n' > "$TMP"d
+cat "$TMP"b | tr -s ' ' '\n' > "$TMP"e
 
 #send output to screen or text file
 if [ -z "$GIS_OPT_OUTPUT" ] 
 then
-	RESULTADO=`cat "$TMP"b`
-	echo "y = a + b*x"
-        echo "   a: offset"
-        echo "   b: gain"
-        echo "   R: sumXY - sumX*sumY/tot"
-        echo "   N: number of elements"
-        echo "   medX, medY: Medians"
-        echo "   sdX, sdY: Standard deviations"
-        echo "a  b  R  N  F medX  sdX  medY  sdY"
-        echo ${RESULTADO}
+	if [ $GIS_FLAG_G -eq 1 ] ; then
+	   paste -d'=' "$TMP"d "$TMP"e
+	else
+	   echo "y = a + b*x"
+           echo "   a: offset"
+           echo "   b: gain"
+           echo "   R: sumXY - sumX*sumY/tot"
+           echo "   N: number of elements"
+           echo "   medX, medY: Medians"
+           echo "   sdX, sdY: Standard deviations"
+           echo "a  b  R  N  F medX  sdX  medY  sdY"
+	   RESULTADO=`cat "$TMP"b`
+           echo ${RESULTADO}
+	fi
 else
-        echo "y = a + b*x"
-        echo "   a: offset"
-        echo "   b: gain"
-        echo "   R: sumXY - sumX*sumY/tot"
-        echo "   N: number of elements"
-        echo "   medX, medY: Medians"
-        echo "   sdX, sdY: Standard deviations"
-	echo "a  b  R  N  F medX  sdX  medY  sdY" > "$TMP"c
-	cat "$TMP"b >> "$TMP"c
+	if [ $GIS_FLAG_G -eq 1 ] ; then
+	   paste -d'=' "$TMP"d "$TMP"e >> "$TMP"c
+	else
+	   echo "y = a + b*x" > "$TMP"c
+           echo "   a: offset" >> "$TMP"c
+           echo "   b: gain" >> "$TMP"c
+           echo "   R: sumXY - sumX*sumY/tot" >> "$TMP"c
+           echo "   N: number of elements" >> "$TMP"c
+           echo "   medX, medY: Medians" >> "$TMP"c
+           echo "   sdX, sdY: Standard deviations" >> "$TMP"c
+           echo "a  b  R  N  F medX  sdX  medY  sdY" >> "$TMP"c
+	   cat "$TMP"b >> "$TMP"c
+	fi
 	mv "$TMP"c "$GIS_OPT_OUTPUT"
 	cat "$GIS_OPT_OUTPUT"
 fi
-rm -f "$TMP" "$TMP"b "$TMP"c
+rm -f "$TMP" "$TMP"b "$TMP"c "$TMP"d "$TMP"e




More information about the grass-commit mailing list