r.regression.line(1)
β¨ r.regression.line β¨
okay bestie, welcome to r.regression.line π this is the GRASS GIS User's Manual page for it, and we're about to make linear regression sound as cute as it actually is. (It's very cute. Trust.) π
It does raster, statistics, and regression β those are the keywords, iykyk. πΈ
π NAME π
r.regression.line β calculates linear regression from two raster maps: y = a + b*x. literally the whole job π
π¦ SYNOPSIS π¦
r.regression.line
r.regression.line --help
r.regression.line [-g] mapx=name mapy=name [output=name]
[--overwrite] [--help] [--verbose] [--quiet] [--ui]
π Flags π
-gβ print it in shell script style, so it's allvariable=valuecoded and ready to beeval'd. obsessed.--overwriteβ lets output files overwrite existing files. yes bestie, it will absolutely replace them, no cap.--helpβ prints the usage summary. your bestie when you forget stuff π«Ά--verboseβ verbose module output. the module gets chatty. we love that.--quietβ quiet module output. the module shuts up. also valid.--uiβ forces launching the GUI dialog. clicky-clicky mode π±οΈ
πΈ Parameters πΈ
mapx=name[required] β the map for the x coefficient. not optional, bestie, don't skip it.mapy=name[required] β the map for the y coefficient. also required. also don't skip it.output=nameβ an ASCII file for storing the regression coefficients. if you don't name a file, it just prints to the screen instead. main character behavior honestly.
π DESCRIPTION π
So. r.regression.line calculates a linear regression from two raster maps, according to this formula:
y = a + b*x
where x and y represent the input raster maps. that's it. that's the vibe. β¨
Optionally, it saves regression coefficients as an ASCII file. and the result includes all of these little icons:
- offset/intercept (
a) - 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)
a whole little squad of statistics. π
π NOTES π
ngl the glow-up here is real: the results for offset/intercept (a) and gain/slope (b) are identical to what you get from R-stats's lm() function. same numbers, different font. π
π§ EXAMPLE π§
Comparison of two DEMs (SRTM and NED, both at 30m resolution), provided in the North Carolina sample dataset:
g.region raster=elev_srtm_30m -p
r.regression.line mapx=elev_ned_30m mapy=elev_srtm_30m
y = a + b*x
a (Offset): -1.659279
b (Gain): 1.043968
R (sumXY - sumX*sumY/N): 0.894038
N (Number of elements): 225000
F (F-test significance): 896093.366283
meanX (Mean of map1): 110.307571
sdX (Standard deviation of map1): 20.311998
meanY (Mean of map2): 113.498292
sdY (Standard deviation of map2): 23.718307
Using the script style flag AND eval to make results available in the shell β this is the moment, bestie:
g.region raster=elev_srtm_30m -p
eval `r.regression.line -g mapx=elev_ned_30m mapy=elev_srtm_30m`
# print result stored in respective variables
echo $a
-1.659279
echo $b
1.043968
echo $R
0.894038
π SEE ALSO π
d.correlate, r.regression.multi, r.stats β go read those too, they're all in the same friend group π«Ά
π AUTHORS π
- Dr. Agustin Lobo - alobo at ija.csic.es
- Updated to GRASS 5.7 Michael Barton, Arizona State University
- Script style output Markus Neteler
- Conversion to C module Markus Metz
π₯ SOURCE CODE π₯
Available at: r.regression.line source code (history)
Accessed: Saturday Jan 17 05:40:57 2026
Main index | Raster index | Topics index | Keywords index | Graphical index | Full index
Β© 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual
and that's the whole page, bestie π this was GRASS GIS 8.4.2, documented in that reference manual we just mentioned, and last accessed on Saturday Jan 17 05:40:57 2026 β go run a regression, you're gonna slay β¨ππ
π¦ where this page comes from
- fedora 44: grass 8.4.2-4.fc44 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms