r.regression.line Calculates linear regression from two raster maps, according to the formula y = a + b*x, where x and y represent raster maps. Optionally saves regression coefficients to an ASCII file. The result includes the following coefficients: offset/intercept (a) and gain/slope (b), correlation coefficient (R), 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).


The results for offset/intercept (a) and gain/slope (b) are identical to that obtained from R-stats's lm() function.

The flag -s is inactive as always high precision is calculated (kept for backward compatibility).


Comparison of the old and the new DEM in Spearfish:
g.region rast=elevation.10m -p
r.regression.line map1=elevation.dem map2=elevation.10m

Using the script style flag AND eval to make results available in the shell:

g.region rast=elevation.10m -p
eval `r.regression.line -g map1=elevation.dem map2=elevation.10m`
echo $a

echo $b

echo $R


Dr. Agustin Lobo - alobo at
Updated to GRASS 5.7 Michael Barton, Arizona State University
Script style output Markus Neteler
Conversion to C module Markus Metz

Last changed: $Date$