r.regression.line(1grass)
π r.regression.line β the GRASS manual, but make it a group chat
okay so bestie, welcome to r.regression.line from the GRASS User's Manual (that's r.regression.line(1grass) if you're being formal at a party). This little icon calculates a linear regression from two raster maps, like:
y = a + b*x
She's giving stats girlie, she's giving slope-and-intercept, she's giving math. Let's get into it π
β¨ KEYWORDS β¨
raster, statistics, regression β yeah exactly, she's a raster statistics regression kind of queen π
π¦ SYNOPSIS π¦
r.regression.line
r.regression.line --help
r.regression.line [-g] mapx=name mapy=name [output=name] format=name
[--overwrite] [--help] [--verbose] [--quiet] [--ui]
π© Flags π©
-gβ Print in shell script style[deprecated]. Bestie, listen: this flag is deprecated and is gonna get removed in a future release. Useformat=shellinstead, ok? Don't be messy. π--overwriteβ Lets output files overwrite files that already exist (yes, she will eat your old file, no cap).--helpβ Prints the usage summary, i.e. the "what is this even" screen π«Ά--verboseβ Verbose module output, she will talk more.--quietβ Quiet module output, she will talk less π€«--uiβ Force launches the GUI dialog. Main character GUI energy.
π Parameters π
mapx=name[required]β The map for the x coefficient.mapy=name[required]β The map for the y coefficient.output=nameβ ASCII file for storing the regression coefficients. If you don't give her a file, she just outputs to the screen. Iconic, low maintenance.format=name[required]β Output format.- Options:
plain,shell,json - Default:
plain plain: Human readable text outputshell: shell script style text outputjson: JSON (JavaScript Object Notation)
- Options:
πΈ DESCRIPTION πΈ
okay so r.regression.line calculates a linear regression from two raster maps, according to the formula
y = a + b*x
where x and y represent the input raster maps. yes the variables are just vibing there, they're the maps, that's the whole thing.
Optionally, she saves the 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). That's a whole lot of numbers, but every single one of them is your friend π
β NOTES β
The results for offset/intercept (a) and gain/slope (b) are identical to that obtained from R-stats's lm() function. so if you're an R bestie, come on in, the water's fine π§
π₯ 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:
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
the way that eval backtick combo just drops the variables straight into your shellβ¦ obsessed, fr fr π
π SEE ALSO π
d.correlate, r.regression.multi, r.stats
π 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
look at this lineup, absolute legends, each and every one π«Ά
π SOURCE CODE π
Available at: r.regression.line source code (history)
Latest change: Thursday Oct 02 14:39:13 2025 in commit: 1850489bf42c72d8dcfe2e4db1738441b4a7dc43
Main index | Raster index | Topics index | Keywords index | Graphical index | Full index
k bye bestie, go run your regression π β¨
Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual β and this page was living its best life as r.regression.line(1grass) in GRASS 8.5.0. slay, periodt π
π¦ where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 Β· GPL-2.0-or-later
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· 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