GDAL-RASTER-COMPARE(1) GDAL GDAL-RASTER-COMPARE(1)

gdal-raster-compare - Compare two raster dataset

Added in version 3.12.

Usage: gdal raster compare [OPTIONS] <REFERENCE> <INPUT>
Compare two raster datasets.
Positional arguments:
  --reference <REFERENCE>              Reference dataset [required]
  -i, --input <INPUT>                  Input raster dataset [required] [not available in pipelines]
Common Options:
  -h, --help                           Display help message and exit
  --json-usage                         Display usage as JSON document and exit
  --config <KEY>=<VALUE>               Configuration option [may be repeated]
  -q, --quiet                          Quiet mode (no progress bar or warning message) [not available in pipelines]
Options:
  --skip-all-optional                  Skip all optional comparisons
  --skip-binary                        Skip binary file comparison
  --skip-crs                           Skip CRS comparison
  --skip-geotransform                  Skip geotransform comparison
  --skip-overview                      Skip overview comparison
  --skip-metadata                      Skip metadata comparison
  --skip-rpc                           Skip RPC metadata comparison
  --skip-geolocation                   Skip Geolocation metadata comparison
  --skip-subdataset                    Skip subdataset comparison
Advanced Options:
  --if, --input-format <INPUT-FORMAT>  Input formats [may be repeated] [not available in pipelines]
  --oo, --open-option <KEY>=<VALUE>    Open options [may be repeated] [not available in pipelines]

gdal raster compare compares two GDAL supported datasets and reports the differences. In addition to reporting differences to the standard output, the program will also return the difference count in its exit value.

As a convention, the first dataset specified as a positional argument, or through --reference, is assumed to be the reference/exact/golden dataset. The second dataset specified as a positional argument, or through --input, is the dataset compared to the reference dataset.

Image pixels, and various metadata are checked. There is also a byte by byte comparison done which will count as one difference. So, if it is only important that the GDAL visible data is identical, a difference count of 1 (the binary difference) should be considered acceptable, or you may specify --skip-binary to omit byte to byte comparison.

This program can also be used as the last step of a raster pipeline.

The following options are available:

The dataset being compared to the reference dataset, referred to as the input dataset.
The dataset that is considered correct, referred to as the reference dataset.
Whether to skip all optional tests. This is an alias to defining all other --skip-XXXX options.

The remaining non-optional tests are:

  • checking dataset width, height and band count
  • checking band description, data type, color interpretation and nodata value
  • checking pixel content
Whether to skip exact comparison of binary content.
Whether to skip comparison of coordinate reference systems (CRS).
Whether to skip comparison of GEOLOCATION metadata domain.
Whether to skip comparison of geotransform matrix.
Whether to skip comparison of metadata
Whether to skip comparison of overviews.
Whether to skip comparison of Rational Polynomial Coefficients (RPC) metadata domain.
Whether to ignore comparison of all subdatasets that are part of the dataset.

Format/driver name to be attempted to open the input file(s). It is generally not necessary to specify it, but it can be used to skip automatic driver detection, when it fails to select the appropriate driver. This option can be repeated several times to specify several candidate drivers. Note that it does not force those drivers to open the dataset. In particular, some drivers have requirements on file extensions.

May be repeated.

Dataset open option (format specific).

May be repeated.

The program returns status code 0 in case of success, and non-zero in case of error (non-blocking errors emitted as warnings are considered as a successful execution).

$ gdal raster compare autotest/gcore/data/byte.tif autotest/gcore/data/uint16.tif
Reference file has size 736 bytes, whereas input file has size 1136 bytes.
Reference band 1 has data type Byte, but input band has data type UInt16
$ echo $?
2

$ gdal raster pipeline read test_in_foot.tif ! calc --calc "X * 0.3048" ! compare --reference=reference_in_meter.tif

Even Rouault <even.rouault@spatialys.com>

1998-2026

August 18, 2026