pkdiff(1)

✨ pkdiff β€” bestie edition ✨

okay so you want to compare two raster images?? say less πŸ’… welcome to pkdiff, a lil program that compares two raster image files and tells you what's up. it's giving main character energy and honestly it ate.


🌸 NAME 🌸

pkdiff β€” the program that compares two raster image files. that's it. that's the whole vibe. πŸ¦‹


✨ SYNOPSIS ✨

pkdiff -i input -ref reference [options] [advanced options]

πŸ’– DESCRIPTION πŸ’–

okay so pkdiff compares two datasets. here's the tea tho: the reference can be either a raster or a vector, but the input has to be a raster dataset, periodt. no exceptions bestie.

when the reference is a raster dataset, you get a pixel by pixel comparison. iconic. and if you don't add any extra options, the utility just tells you whether the rasters are identical or different β€” that's it, that's the whole report. simple. clean.

but wait, there's more 🌈 if you want, you can write an output raster dataset with a lil qualitative piece of info per pixel:

  • 0 β€” input = reference
  • 1 β€” input > reference
  • 2 β€” input < reference

now if the reference is a vector dataset instead?? it has to consist of point features. and if you hit it with polygon features, they get automatically converted to the centroid points before analyzing. the utility said "not today polygons" πŸ’€

a super typical use of this utility is assessing 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 -cm|--confusion is set. and 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. so organized. so slay. πŸ‘‘


πŸŽ€ OPTIONS πŸŽ€

  • -i filename, --input filename β€” Input raster dataset. yes you literally have to give it something to look at.
  • -ref filename, --reference filename β€” Reference (raster or vector) dataset. this is the thing you're comparing against, bestie.
  • -ln layer, --ln layer β€” Layer name(s) in sample. Leave empty to select all (for vector reference datasets only). leave it blank and it grabs everything 🫢
  • -b band, --band band β€” Input raster band. which band are we looking at, hmm?
  • -cm, --confusion β€” Create confusion matrix (to stdout). the name is scary but it's just math, i promise 😭
  • -lr attribute, --lref attribute β€” Attribute name of the reference label (for vector reference datasets only).
  • -c name, --class name β€” List of class names.
  • -r value, --reclass value β€” List of class values (use same order as in classname option). keep the order matching, don't play yourself πŸ™ˆ
  • -nodata value, --nodata value β€” No data value(s) in input or reference dataset are ignored. we simply do not perceive them ✨
  • -m mask, --mask mask β€” Use the first band of the specified file as a validity mask. No-data values can be set with the option --msknodata.
  • -msknodata value, --msknodata value β€” Mask value(s) where image is invalid. Use negative value for valid data (example: use -t -1: if only -1 is valid value). yes the negative means valid, it's confusing, i know, just go with it πŸ’€
  • -v level, --verbose level β€” verbose level. how much do you wanna hear about it? πŸ‘€

πŸ”₯ Advanced options πŸ”₯

  • -o output, --output output β€” Output dataset (optional). only if you want the receipts.
  • -f OGRformat, --f OGRformat β€” OGR format for output vector (for vector reference datasets only).
  • -of GDALformat, --oformat GDALformat β€” Output image format (see also gdal_translate(1)). Empty string: inherit from input image. lazy girl friendly 🌸
  • -lc attribute, --lclass attribute β€” Attribute name of the classified label (for vector reference datasets only).
  • --commission value β€” Value for commission errors: input label < reference label.
  • -bnd value, --boundary value β€” Boundary for selecting the sample (for vector reference datasets only).
  • -hom, --homogeneous β€” Only take regions with homogeneous boundary into account (for reference datasets only).
  • -circ, --circular β€” Use circular boundary (for vector reference datasets only). we're going in circles, literally πŸ’«
  • -ct colortable, --ct colortable β€” Color table in ASCII format having 5 columns: id R G B ALFA (0: transparent, 255: solid). alpha but make it ALFA iykyk.
  • -co NAME=VALUE, --co NAME=VALUE β€” Creation option for output file. Multiple options can be specified. stack 'em up bestie ✨

🌈 EXAMPLE 🌈

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

pkdiff -i input.tif -ref reference.tif

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

pkdiff -i classificationMap.tif -ref referencePoints.tif -cm

ngl bestie, if you got this far you're officially a raster girlie. go forth and diff. πŸ’…

written 01 January 2025, from the pkdiff(1) manual β€” mwah, love u, bye 🫢✨

πŸ“¦ where this page comes from