[GRASS-user] Calculating eigen values and % varianceexplainedafter PCA analysis

Wesley Roberts wroberts at csir.co.za
Fri Feb 27 04:44:43 EST 2009


Dear Nikos and list,

I downloaded and installed GRASS 6.4 and after much "wailing and gnashing of teeth" I got m.eigensystem to work. Below are some comments and questions.

Over the last couple of days I have been running PCA analyses using the i.pca and r.covar -> m.eigensystem -> r.mapcalc. The analysis seeks to create a component surface where tree crowns are separated from understory and ground in a plantation forest. Inputs are three digital aerial photographs (red, green, blue), a top of canopy height model, and an intensity surface derived from lidar return intensity measures. Output from the PCA will be input into a tree couting method which (if all goes well) will use mathematical morphology to isolate tree crowns for counting purposes

My results are interesting and worth mentioning to the list. Firstly, the results from both the automated (i.pca) and the 'by-hand-method' (r.covar -> m.eigensystem -> r.mapcalc) differ. For example; the eigen values from the automated approach are as follows

(-0.50 -0.53 -0.49 -0.47 -0.08)

(-0.38 -0.30 -0.13 0.86 0.11)

(-0.34 -0.35 0.86 -0.14 0.05)

(0.70 -0.71 -0.01 0.06 0.03)

(0.00 -0.03 0.07 0.13 -0.99)

while the eigen values from the 'by-hand-method' are completely different, in fact I am a little confused with regards to the ouput from i.pca and the m.eigensystem.

i.pca returns the n number of components plus the eigen values for each component (or are those vectors?). Would it be fair in saying that these are the coefficients which have been applied to the input imagery to attain the output components (in the same way the m.eigensystem works with r.mapcalc)? Output from the m.eigensystem approach only gives one eigen value per component (see below). Are the above values from i.pca not the eigen vectors? If this is the case then both methods still differ significantly. Is this possible, and which should I use. 

Qualitatively, the 'by-hand-method' seems to isolate the crowns very nicely in PC1 while the automated (i.pca) approach isolates crowns in PC3?? I rescaled the output in the i.pca method, would this contribute to the differences seen?

I am going to run more tests on the rest of my data and will see if these issues arise again. In the meantime if anyone of the list can offer some insight into the two different pca analysis examples I would greatly appreciate it.

Many thanks and kind regards,
Wesley

PC1
E      3759.8207866502         0.0000000000    89.81
V        -0.7126171230         0.0000000000
V        -0.7014527001         0.0000000000
V        -0.5479326672         0.0000000000
V        -0.0063691433         0.0000000000
V         0.0003086030         0.0000000000
N        -0.6249753328         0.0000000000
N        -0.6151839755         0.0000000000
N        -0.4805447273         0.0000000000
N        -0.0055858291         0.0000000000
N         0.0002706492         0.0000000000
W       -38.3218484280         0.0000000000
W       -37.7214680719         0.0000000000
W       -29.4657424614         0.0000000000
W        -0.3425083898         0.0000000000
W         0.0165955013         0.0000000000
PC3
E        83.1252237615         0.0000000000     1.99
V         0.2494768845         0.0000000000
V         0.2555418427         0.0000000000
V        -0.6518350827         0.0000000000
V         0.0206244955         0.0000000000
V         0.0053148479         0.0000000000
N         0.3355163716         0.0000000000
N         0.3436730101         0.0000000000
N        -0.8766397026         0.0000000000
N         0.0277374632         0.0000000000
N         0.0071478305         0.0000000000
W         3.0590046010         0.0000000000
W         3.1333711503         0.0000000000
W        -7.9925902599         0.0000000000
W         0.2528908714         0.0000000000
W         0.0651689407         0.0000000000
PC4
E        19.5501569351         0.0000000000     0.47
V         0.7054176684         0.0000000000
V        -0.7117116152         0.0000000000
V        -0.0069731939         0.0000000000
V         0.0578916991         0.0000000000
V         0.0277215748         0.0000000000
N         0.7025026853         0.0000000000
N        -0.7087706239         0.0000000000
N        -0.0069443787         0.0000000000
N         0.0576524745         0.0000000000
N         0.0276070215         0.0000000000
W         3.1061549216         0.0000000000
W        -3.1338689624         0.0000000000
W        -0.0307049588         0.0000000000
W         0.2549136409         0.0000000000
W         0.1220659899         0.0000000000
PC2
E       322.3045348724         0.0000000000     7.70
V        -0.0625878598         0.0000000000
V         0.0327193611         0.0000000000
V         0.0258859244         0.0000000000
V         1.1718777756         0.0000000000
V        -0.0080859959         0.0000000000
N        -0.0532972371         0.0000000000
N         0.0278624569         0.0000000000
N         0.0220433843         0.0000000000
N         0.9979227246         0.0000000000
N        -0.0068857002         0.0000000000
W        -0.9568368746         0.0000000000
W         0.5002102855         0.0000000000
W         0.3957413952         0.0000000000
W        17.9155489758         0.0000000000
W        -0.1236178876         0.0000000000
PC5
E         1.6296377808         0.0000000000     0.04
V        -0.0220049147         0.0000000000
V         0.0174806810         0.0000000000
V         0.0067441814         0.0000000000
V         0.0050864663         0.0000000000
V         0.9998141827         0.0000000000
N        -0.0219995304         0.0000000000
N         0.0174764038         0.0000000000
N         0.0067425312         0.0000000000
N         0.0050852217         0.0000000000
N         0.9995695447         0.0000000000
W        -0.0280839993         0.0000000000
W         0.0223098995         0.0000000000
W         0.0086073311         0.0000000000
W         0.0064916550         0.0000000000
W         1.2760231622         0.0000000000






Wesley Roberts MSc.
Researcher: Earth Observation (Ecosystems)
Natural Resources and the Environment
CSIR
Tel: +27 (21) 888-2490
Fax: +27 (21) 888-2693

"To know the road ahead, ask those coming back."
- Chinese proverb

>>> Nikos Alexandris <nikos.alexandris at felis.uni-freiburg.de> 02/25/09 3:47 PM >>>

Nikos:
> If you have success running m.eigensystem, can I please ask you to let
> the list (and me :-p) know about it? I compiled m.eigensystem without
> errors but it doesn't seem to work within from grass65. I am currently
> re-compiling grass6_devel to see whether it will work or not.
> 
> Or do I need to work with grass6.4?


# Answering to myself :-p

Yes, it works. I was confused by the fact that nomatter what argument is
given to m.eigensystem it does not print short description/help
messages. Instead it runs. Of course "man m.eigensystem" lets you read
the manual.

So here is an(other) example:


        # get covariance matrix
        r.covar
        map=MOD2006_239_500_sur_refl_b02,MOD2006_239_500_sur_refl_b06,MOD2006_239_500_sur_refl_b07,MOD2007_242_500_sur_refl_b02,MOD2007_242_500_sur_refl_b06,MOD2007_242_500_sur_refl_b07
        
        r.covar: complete ...
         100%
        230737.894890 195532.919270 135003.507092 160548.524865
        157011.283237 109163.152597 
        195532.919270 370156.630631 302611.016829 169840.571354
        329762.496795 255222.040018 
        135003.507092 302611.016829 269579.148609 123245.319257
        267537.923455 218257.721900 
        160548.524865 169840.571354 123245.319257 283021.657148
        227212.808304 97810.797191 
        157011.283237 329762.496795 267537.923455 227212.808304
        411853.700150 306427.271345 
        109163.152597 255222.040018 218257.721900 97810.797191
        306427.271345 287565.577718 
        
        
        # output in a file
        r.covar
        map=MOD2006_239_500_sur_refl_b02,MOD2006_239_500_sur_refl_b06,MOD2006_239_500_sur_refl_b07,MOD2007_242_500_sur_refl_b02,MOD2007_242_500_sur_refl_b06,MOD2007_242_500_sur_refl_b07 > test_m.eigensystem
        
        
        # edit the file and add a number K which corresponds to the
        number of rows and columns of the cov matrix
        # in my example: add the number "6" in the top line of the
        test_m.eigensystem file
        
        
        # run m.eigensystem
        m.eigensystem < test_m.eigensystem
        
        E   1384795.0108207434          .0000000000    74.74
        V          .4835516921          .0000000000
        V          .8488469532          .0000000000
        V          .6938880512          .0000000000
        V          .5233792650          .0000000000
        V          .8927982533          .0000000000
        V          .6795723454          .0000000000
        N          .2806476574          .0000000000
        N          .4926606871          .0000000000
        N          .4027243813          .0000000000
        N          .3037631075          .0000000000
        N          .5181694995          .0000000000
        N          .3944157157          .0000000000
        W       330.2586235389          .0000000000
        W       579.7498611168          .0000000000
        W       473.9152326520          .0000000000
        W       357.4602642457          .0000000000
        W       609.7679463257          .0000000000
        W       464.1378182325          .0000000000
        E    241514.2792070895          .0000000000    13.03
        
        [...]
        
        
        



-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.



More information about the grass-user mailing list