.TH r.covar 1grass "" "GRASS 7.8.5" "GRASS GIS User's Manual" .SH NAME \fI\fBr.covar\fR\fR \- Outputs a covariance/correlation matrix for user\-specified raster map layer(s). .SH KEYWORDS raster, statistics .SH SYNOPSIS \fBr.covar\fR .br \fBr.covar \-\-help\fR .br \fBr.covar\fR [\-\fBr\fR] \fBmap\fR=\fIname\fR[,\fIname\fR,...] [\-\-\fBhelp\fR] [\-\-\fBverbose\fR] [\-\-\fBquiet\fR] [\-\-\fBui\fR] .SS Flags: .IP "\fB\-r\fR" 4m .br Print correlation matrix .IP "\fB\-\-help\fR" 4m .br Print usage summary .IP "\fB\-\-verbose\fR" 4m .br Verbose module output .IP "\fB\-\-quiet\fR" 4m .br Quiet module output .IP "\fB\-\-ui\fR" 4m .br Force launching GUI dialog .SS Parameters: .IP "\fBmap\fR=\fIname[,\fIname\fR,...]\fR \fB[required]\fR" 4m .br Name of raster map(s) .SH DESCRIPTION \fIr.covar\fR outputs a covariance/correlation matrix for user\-specified raster map layer(s). The output can be printed, or saved by redirecting output into a file. .PP The output is an N x N symmetric covariance (correlation) matrix, where N is the number of raster map layers specified on the command line. .SH NOTES This module can be used as the first step of a principle components transformation. The covariance matrix would be input into a system which determines eigen values and eigen vectors. An NxN covariance matrix would result in N real eigen values and N eigen vectors (each composed of N real numbers). .PP The module \fIm.eigensystem\fR in GRASS GIS Addons can be compiled and used to generate the eigen values and vectors. .SH EXAMPLE For example, .br .nf \fC g.region raster=layer.1 \-p r.covar \-r map=layer.1,layer.2,layer.3 \fR .fi would produce a 3x3 matrix (values are example only): .br .nf \fC 1.000000 0.914922 0.889581 0.914922 1.000000 0.939452 0.889581 0.939452 1.000000 \fR .fi In the above example, the eigen values and corresponding eigen vectors for the covariance matrix are: .br .nf \fC component eigen value eigen vector 1 1159.745202 <0.691002 0.720528 0.480511> 2 5.970541 <0.711939 \-0.635820 \-0.070394> 3 146.503197 <0.226584 0.347470 \-0.846873> \fR .fi The component corresponding to each vector can be produced using \fIr.mapcalc\fR as follows: .br .nf \fC r.mapcalc \(dqpc.1 = 0.691002*layer.1 + 0.720528*layer.2 + 0.480511*layer.3\(dq r.mapcalc \(dqpc.2 = 0.711939*layer.1 \- 0.635820*layer.2 \- 0.070394*layer.3\(dq r.mapcalc \(dqpc.3 = 0.226584*layer.1 + 0.347470*layer.2 \- 0.846873*layer.3\(dq \fR .fi Note that based on the relative sizes of the eigen values, \fIpc.1\fR will contain about 88% of the variance in the data set, \fIpc.2\fR will contain about 1% of the variance in the data set, and \fIpc.3\fR will contain about 11% of the variance in the data set. Also, note that the range of values produced in \fIpc.1\fR, \fIpc.2\fR, and \fIpc.3\fR will not (in general) be the same as those for \fIlayer.1\fR, \fIlayer.2\fR, and \fIlayer.3\fR. It may be necessary to rescale \fIpc.1\fR, \fIpc.2\fR and \fIpc.3\fR to the desired range (e.g. 0\-255). This can be done with \fIr.rescale\fR. .SH SEE ALSO \fI i.pca, m.eigensystem (Addon), r.mapcalc, r.rescale \fR .SH AUTHOR Michael Shapiro, U.S. Army Construction Engineering Research Laboratory .SH SOURCE CODE .PP Available at: r.covar source code (history) .PP Main index | Raster index | Topics index | Keywords index | Graphical index | Full index .PP © 2003\-2020 GRASS Development Team, GRASS GIS 7.8.5 Reference Manual