ctab: Calculate contingency table

View source: R/ctab.R

ctabR Documentation

Calculate contingency table

Description

Calculation of contingency table from two rasters with categorical data

Usage

ctab(a, b, mask = "")

Arguments

a

An object of type "raster" containing categorical data

b

An object of type "raster" containing categorical data. Must be of the same dimensions as a.

mask

A string vector of category numbers which are are to be ignored in the calculations. The numbers must be identical to the values of the input rasters.

Value

An object of class "matrix"

Author(s)

Hanna Meyer

See Also

For calculation of kappa indices see kstat

Examples

#### Example 1: Calculate the contingency table from two Land cover maps
#load data
library(raster)
LUC1990 <- raster(system.file("LUC1990.rst", package="Rsenal"))
LUC2006 <- raster(system.file("LUC2006.rst", package="Rsenal"))

#plot to get an impression:
par(mfrow=c(1,2))
plot(LUC1990,main="LUC Marburg 1990")
plot(LUC2006,main="LUC Marburg 2006")

#calculate contingency table:
ctab(LUC1990,LUC2006)


#### Example 2: Calculate the contingency table from a land cover map 
#and a map of ground truth sites
#load data
LUC1990 <- raster(system.file("LUC1990.rst", package="Rsenal"))
trainingSites <- raster(system.file("training.rst", package="Rsenal"))

#plot to get an impression:
par(mfrow=c(1,2))
plot(LUC1990,main="LUC Marburg 1990")
plot(trainingSites,main="Training sites (Ground truth)")

#calculate contingency table:
#(consider to mask the background since ground truth sites don't cover the whole area)
ctab(LUC1990,trainingSites,mask="0")


environmentalinformatics-marburg/Rsenal documentation built on July 28, 2023, 6:09 a.m.