I did a supervised classification of a Landsat image subset using my training data polygons. I used SAGA GIS for that and everything worked out fine. Now I am stuck since I have no clue how to prepare the confusion matrix using my test polygons!

I know that I need for each polygon the number of pixels of the different classes, i.e. a cross tabulation.

How could one achieve that?

And yes, I know that there is this semi-automatic image classification plugin for QGIS and so forth, but I would like to understand the process of generating the confusion matrix itself from scratch.


1 Answer 1


Given the case that you are trying to measure the accuracy of a supervised classification, then generally you also have test samples, usually polygons. In SAGA, one has to convert these polyons into a grid with:

Module: Grid - Gridding -- Shapes to grid

After that, one can use that new grid in the zonal statistic tool found in the module:

Spatial and Geostatistics - Grids -- Zonal Grid Statistics

That leads to a table having (at least) three columns, where one (count UCU) holds the number of cells/pixels per test class and classified class. This table can then be turned into the classical confusion matrix, from which Kappa etc can be calculated.

  • 1
    +1 Great solution. An interesting read regarding Kappa: Pontius Jr, Robert Gilmore, and Marco Millones. "Death to Kappa: birth of quantity disagreement and allocation disagreement for accuracy assessment." International Journal of Remote Sensing 32.15 (2011): 4407-4429.
    – Aaron
    Commented Dec 30, 2013 at 19:15
  • Thx Aaron! Nice paper indeed. Hmm...how to program that in R...
    – Jens
    Commented Feb 10, 2014 at 14:39
  • This answer is outdated because SAGA 7.0.0 has two new toolboxes called "Confusion Matrix" one for points/grids and another for grid/grid data. No need to make the Zonal Grid Statistics.
    – Jens
    Commented Dec 11, 2018 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.