Principal Component Analysis (PCA) using ILWIS open source software


Today we will learn how to employ PCA in ILWIS opensource software environment, OK let’s begin:

1. Our study area is around Kurdistan, Iran. We will use Landsat 5TM image from USGS, the acquisition date is July 5th, 2011. Firstly, open your ILWIS software and import all your tiff images into ILWIS format using the following algorithm:

import tiff file

2. Double click “Principal Components” in the Operation-List window (left side), the following window will appear, if you don’t have MapList, create MapList first with click the yellow button, and input from band B1-B5 and B7

PCA window and create MapList

3. The following window (Principal Component Coefficients) will appear when you click “Show”.

4. Write down in your paper the eigenvalues from b1-b7 (right window), and calculate the PC1-PC3 using the algorithm in the left window

The first two or three components will carry most of the real information of the original data set, while the later components describe only the minor variations (sometimes only noise). Therefore, only by keeping the first few components most of the information is kept. These components can be used to generate an RGB color composite, in which component 1 is displayed in red and component 2 and 3 in green and blue respectively. Such an image contains more information than any combination of the three original spectral bands.

Through this type of image transformation the relationship with raw image data is lost. The basis is the covariance matrix from which the eigenvectors and eigenvalues are mathematically derived. It should be noted that the covariance values computed are strongly depending on the actual data set or subset used, therefore the atmospheric correction is mandatory for images with too much noise.

5. Create a color composite of the PC1 (Red), PC2 (Green), PC3 (Blue)

PCA color composite

6. Filter your PC-RGB data using “Majority” model to reduce spatial frequency of your data

Right click on your PCA-RGB data and choose “Image Processing-Filter”, then choose “Majority”

7. Create; a. RGB from the original spectral bands (742 band false color); b. 432 false color. Just double click “Color Composite” in the Operation List window on the left side of the software, and input your data.

8. Compare the result with composite of the PC1 (Red), PC2 (Green), PC3 (Blue)

Compare these three color composite maps.

9. QUIZ!

A. What are the differences between three different color composite maps?

B. Can you define the top soil classification from the map?

C. Explain the contribution of the TM bands in PC2 and PC3?

One of the many applications of this method is mapping geological structures or top soil in Arid areas.



  1. Hi! Thanks for posting this. It helped me a lot as i am trying out PCA using ILWIS for the first time (have not touched ILWIS before). I was doing one on ArcMap and R too but i want to compare the results.

    Unfortunately, I after i made my map list, and ran Principal Components, ILWIS encountered an error (3803) and stops working. I checked my rasters and they are all of the same spatial extent and projection. Have you ever encountered this problem? Maybe my data is too huge? (whole of Japan).

    Do share if you have any similar experiences. Otherwise it is okay too 🙂

  2. Hi!
    Sorry for the late reply, I just came back to my home country
    I think ILWIS cannot handle such a big data (whole japan)

    If you don’t mind would you upload your data and send me the link?
    I’ll check it myself

  3. Thanks for this post. It really has been helpful. Unfortunately, I did as you instructed but when I wanted to create a color composite of PC1, PC2 and PC3, it is not showing on the list for me to use. Any work around for this? I use ILWIS 3.7. Thanks.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s