r.regression.line1grass
Calculates linear regression from two raster maps: y = a + b*x.
Usage
r.regression.line
r.regression.line --help
r.regression.line [-g]
mapx=name
mapy=name
[output=name]
[--overwrite]
[--help]
[--verbose]
[--quiet]
[--ui]
Keywords
raster, statistics, regression
Overview
r.regression.line calculates a linear regression from two raster maps, according to the formula
y = a + b*x
where
xy
represent the input raster maps.
Optionally, it saves regression coefficients as a 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).
Notes
The results for offset/intercept (a) and gain/slope (b) are identical to that obtained from R-stats’s lm() function.
Examples
Comparison of two DEMs (SRTM and NED, both at 30m resolution), provided in the North Carolina sample dataset:
g.region raster=elev_srtm_30m -pr.regression.line mapx=elev_ned_30m mapy=elev_srtm_30my = a + b*xa (Offset): -1.659279b (Gain): 1.043968R (sumXY - sumX*sumY/N): 0.894038N (Number of elements): 225000F (F-test significance): 896093.366283meanX (Mean of map1): 110.307571sdX (Standard deviation of map1): 20.311998meanY (Mean of map2): 113.498292sdY (Standard deviation of map2): 23.718307
Using the script style flag AND eval to make results available in the shell:
g.region raster=elev_srtm_30m -peval `r.regression.line -g mapx=elev_ned_30m mapy=elev_srtm_30m`# print result stored in respective variablesecho $a-1.659279echo $b1.043968echo $R0.894038
Source code
Available at: r.regression.line source code (history)
Accessed: Monday Feb 24 17:50:48 2025
Main index | Raster index | Topics index | Keywords index | Graphical index | Full index
© 2003-2025 GRASS Development Team, GRASS GIS 8.4.1 Reference Manual
Releases
10 releases since Debian 4.0 (Etch); the text changed 9 times.