1r.covar(1) Grass User's Manual r.covar(1)
2
3
4
6 r.covar - Outputs a covariance/correlation matrix for user-specified
7 raster map layer(s).
8
10 raster, statistics
11
13 r.covar
14 r.covar --help
15 r.covar [-r] map=name[,name,...] [--help] [--verbose] [--quiet]
16 [--ui]
17
18 Flags:
19 -r
20 Print correlation matrix
21
22 --help
23 Print usage summary
24
25 --verbose
26 Verbose module output
27
28 --quiet
29 Quiet module output
30
31 --ui
32 Force launching GUI dialog
33
34 Parameters:
35 map=name[,name,...]Â [required]
36 Name of raster map(s)
37
39 r.covar outputs a covariance/correlation matrix for user-specified
40 raster map layer(s). The output can be printed, or saved by redirect‐
41 ing output into a file.
42
43 The output is an N x N symmetric covariance (correlation) matrix, where
44 N is the number of raster map layers specified on the command line.
45
47 This module can be used as the first step of a principle components
48 transformation. The covariance matrix would be input into a system
49 which determines eigen values and eigen vectors. An NxN covariance
50 matrix would result in N real eigen values and N eigen vectors (each
51 composed of N real numbers).
52
53 The module m.eigensystem in GRASS GIS Addons can be compiled and used
54 to generate the eigen values and vectors.
55
57 For example,
58 g.region raster=layer.1 -p
59 r.covar -r map=layer.1,layer.2,layer.3
60 would produce a 3x3 matrix (values are example only):
61 1.000000 0.914922 0.889581
62 0.914922 1.000000 0.939452
63 0.889581 0.939452 1.000000
64 In the above example, the eigen values and corresponding eigen vectors
65 for the covariance matrix are:
66 component eigen value eigen vector
67 1 1159.745202 <0.691002 0.720528 0.480511>
68 2 5.970541 <0.711939 -0.635820 -0.070394>
69 3 146.503197 <0.226584 0.347470 -0.846873>
70 The component corresponding to each vector can be produced using r.map‐
71 calc as follows:
72 r.mapcalc "pc.1 = 0.691002*layer.1 + 0.720528*layer.2 + 0.480511*layer.3"
73 r.mapcalc "pc.2 = 0.711939*layer.1 - 0.635820*layer.2 - 0.070394*layer.3"
74 r.mapcalc "pc.3 = 0.226584*layer.1 + 0.347470*layer.2 - 0.846873*layer.3"
75 Note that based on the relative sizes of the eigen values, pc.1 will
76 contain about 88% of the variance in the data set, pc.2 will contain
77 about 1% of the variance in the data set, and pc.3 will contain about
78 11% of the variance in the data set. Also, note that the range of val‐
79 ues produced in pc.1, pc.2, and pc.3 will not (in general) be the same
80 as those for layer.1, layer.2, and layer.3. It may be necessary to
81 rescale pc.1, pc.2 and pc.3 to the desired range (e.g. 0-255). This
82 can be done with r.rescale.
83
85 i.pca, m.eigensystem (Addon), r.mapcalc, r.rescale
86
88 Michael Shapiro, U.S. Army Construction Engineering Research Laboratory
89
91 Available at: r.covar source code (history)
92
93 Main index | Raster index | Topics index | Keywords index | Graphical
94 index | Full index
95
96 © 2003-2019 GRASS Development Team, GRASS GIS 7.8.2 Reference Manual
97
98
99
100GRASS 7.8.2 r.covar(1)