---
name: "pkdiff"
section: "1"
platform: "linux"
package: "pktools"
version: "2.6.7.6+ds-6+b3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/pkdiff"
---

# pkdiff(1)

program to compare two raster image files

## NAME

pkdiff - program to compare two raster image files

## SYNOPSIS

FC**pkdiff**F\[0\]  FC**-i**F\[0\] *input* FC**-ref**F\[0\] *reference* \[*options*\] \[*advanced options*\]

## DESCRIPTION

**pkdiff** compares two datasets. The reference can either be a raster or a vector, but the input must be a raster dataset. In case the reference is a raster dataset, a pixel by pixel comparison is performed. With no further options, the utility reports if the rasters are identical or different. If required, an output raster dataset can be written with a qualitative information per pixel: 0 (input=reference), 1 (input\>reference) or 2 (input\<reference). If, however, the reference is a vector dataset, it must consist of point features. Polygon features are automatically converted to the centroid points before analyzing.

A typical use of the utility is to assess the accuracy of an input raster land cover map, based on a reference vector dataset. The reference dataset must contain an attribute (label) for each class. A confusion matrix is produced if the option FC**-cm**F\[0\]\|FC**--confusion**F\[0\] is set. Here too, an output dataset can be written, which will be a vector dataset in this case. It contains the reference feature points with the extracted data value of the raster input dataset as a new attribute.

## OPTIONS

- FC**-i**F\[0\] *filename*, FC**--input**F\[0\] *filename*

  Input raster dataset.

- FC**-ref**F\[0\] *filename*, FC**--reference**F\[0\] *filename*

  Reference (raster or vector) dataset

- FC**-ln**F\[0\] *layer*, FC**--ln**F\[0\] *layer*

  Layer name(s) in sample. Leave empty to select all (for vector reference datasets only)

- FC**-b**F\[0\] *band*, FC**--band**F\[0\] *band*

  Input raster band

- FC**-cm**F\[0\], FC**--confusion**F\[0\]

  Create confusion matrix (to stdout)

- FC**-lr**F\[0\] *attribute*, FC**--lref**F\[0\] *attribute*

  Attribute name of the reference label (for vector reference datasets only)

- FC**-c**F\[0\] *name*, FC**--class**F\[0\] *name*

  List of class names.

- FC**-r**F\[0\] *value*, FC**--reclass**F\[0\] *value*

  List of class values (use same order as in classname option).

- FC**-nodata**F\[0\] *value*, FC**--nodata**F\[0\] *value*

  No data value(s) in input or reference dataset are ignored

- FC**-m**F\[0\] *mask*, FC**--mask**F\[0\] *mask*

  Use the first band of the specified file as a validity mask. Nodata values can be set with the option FC**--msknodata**F\[0\].

- FC**-msknodata**F\[0\] *value*, FC**--msknodata**F\[0\] *value*

  Mask value(s) where image is invalid. Use negative value for valid data (example: use FC**-t**F\[0\] FC-1F\[0\]: if only FC-1F\[0\] is valid value)

- FC**-v**F\[0\] *level*, FC**--verbose**F\[0\] *level*

  verbose level

Advanced options

- FC**-o**F\[0\] *output*, FC**--output**F\[0\] *output*

  Output dataset (optional)

- FC**-f**F\[0\] *OGRformat*, FC**--f**F\[0\] *OGRformat*

  OGR format for output vector (for vector reference datasets only)

- FC**-of**F\[0\] *GDALformat*, FC**--oformat**F\[0\] *GDALformat*

  Output image format (see also [**gdal\_translate**(1)](/gdal_translate/1.md)). Empty string: inherit from input image

- FC**-lc**F\[0\] *attribute*, FC**--lclass**F\[0\] *attribute*

  Attribute name of the classified label (for vector reference datasets only)

- FC**--commission**F\[0\] *value*

  Value for commission errors: input label \< reference label

- FC**-bnd**F\[0\] *value*, FC**--boundary**F\[0\] *value*

  Boundary for selecting the sample (for vector reference datasets only)

- FC**-hom**F\[0\], FC**--homogeneous**F\[0\]

  Only take regions with homogeneous boundary into account (for reference datasets only)

- FC**-circ**F\[0\], FC**--circular**F\[0\]

  Use circular boundary (for vector reference datasets only)

- FC**-ct**F\[0\] *colortable*, FC**--ct**F\[0\] *colortable*

  Color table in ASCII format having 5 columns: id R G B ALFA (0: transparent, 255: solid).

- FC**-co**F\[0\] *NAME=VALUE*, FC**--co**F\[0\] *NAME=VALUE*

  Creation option for output file. Multiple options can be specified.

## EXAMPLE

Check if two raster images are different (reports only if images are different or not)

```
FC
pkdiff -i input.tif -ref reference.tif
      F[0]
```

Validate a classification map using points from a reference sample and report confusion matrix

```
FC
pkdiff -i classificationMap.tif -ref referencePoints.tif -cm
      F[0]
```
