r.kappa.1grass - Man Page

Calculates error matrix and kappa parameter for accuracy assessment of classification result.


raster, statistics, classification


r.kappa --help
r.kappa [-whm] classification=name reference=name  [output=name]   [title=string]   [--overwrite]  [--help]  [--verbose]  [--quiet]  [--ui]



Wide report
132 columns (default: 80)


No header in the report


Print Matrix only


Allow output files to overwrite existing files


Print usage summary


Verbose module output


Quiet module output


Force launching GUI dialog


classification=name [required]

Name of raster map containing classification result

reference=name [required]

Name of raster map containing reference classes


Name for output file containing error matrix and kappa
If not given write to standard output


Title for error matrix and kappa


r.kappa tabulates the error matrix of classification result by crossing classified map layer with respect to reference map layer.  Both overall kappa (accompanied by its variance) and conditional kappa values are calculated.  This analysis program respects the current geographic region and mask settings.

r.kappa calculates the error matrix of the two map layers and prepares the table from which the report is to be created.  kappa values for overall and each classes are computed along with their variances. Also percent of comission and omission error, total correct classified result by pixel counts, total area in pixel counts and percentage of overall correctly classified pixels are tabulated.

The report will be write to an output file which is in plain text format and named by user at prompt of running the program.

The body of the report is arranged in panels.  The classified result map layer categories is arranged along the vertical axis of the table, while the reference map layer categories along the horizontal axis.  Each panel has a maximum of 5 categories (9 if wide format) across the top.  In addition, the last column of the last panel reflects a cross total of each column for each row.  All of the categories of the map layer arranged along the vertical axis, i.e., the reference map layer,  are included in each panel.  There is a total at the bottom of each column representing the sum of all the rows in that column.


It is recommended to reclassify categories of classified result map layer into a more manageable number before running r.kappa on the classified raster map layer. Because r.kappa calculates and then reports information for each and every category.

NA’s in output file mean non-applicable in case MASK exists.

The Estimated kappa value in r.kappa is the value only for one class, i.e. the observed agreement between the classifications for those observations that have been classified by classifier 1 into the class i. In other words, here the choice of reference is important.

It is calculated as:

kpp[i] = (pii[i] - pi[i] * pj[i]) / (pi[i] - pi[i] * pj[i]);

  • pii[i] is the probability of agreement (i.e. number of pixels for which there is agreement divided by total number of assessed pixels)
  • Pi[i] is the probability of classification i having classified the point as i
  • Pj[i] is the probability of classification j having classified the point as i.


Example for North Carolina sample dataset:

g.region raster=landclass96 -p
r.kappa -w classification=landuse96_28m reference=landclass96
# export Kappa matrix as CSV file "kappa.csv"
r.kappa classification=landuse96_28m reference=landclass96 output=kappa.csv -m -h

Verification of classified LANDSAT scene against training areas:

r.kappa -w classification=lsat7_2002_classes reference=training

See Also

g.region, r.category, r.mask, r.reclass, r.report, r.stats


Tao Wen, University of Illinois at Urbana-Champaign, Illinois

Source Code

Available at: r.kappa source code (history)

Accessed: Thursday May 11 12:49:01 2023

Main index | Raster index | Topics index | Keywords index | Graphical index | Full index

© 2003-2023 GRASS Development Team, GRASS GIS 8.2.1 Reference Manual


GRASS 8.2.1 GRASS GIS User's Manual