table of contents
- testing 3.12.3+dfsg-1
- unstable 3.12.3+dfsg-1
- experimental 3.13.0~beta1+dfsg-1~exp1
| GDAL-RASTER-COMPARE(1) | GDAL | GDAL-RASTER-COMPARE(1) |
NAME¶
gdal-raster-compare - Compare two raster dataset
Added in version 3.12.
SYNOPSIS¶
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] 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) 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]
--oo, --open-option <KEY>=<VALUE> Open options [may be repeated]
DESCRIPTION¶
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:
PROGRAM-SPECIFIC OPTIONS¶
- --input <input-dataset>
- The dataset being compared to the reference dataset, referred to as the input dataset.
- --reference <reference-dataset>
- The dataset that is considered correct, referred to as the reference dataset.
- --skip-all-optional
- 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
- --skip-binary
- Whether to skip exact comparison of binary content.
- --skip-crs
- Whether to skip comparison of coordinate reference systems (CRS).
- --skip-geolocation
- Whether to skip comparison of GEOLOCATION metadata domain.
- --skip-geotransform
- Whether to skip comparison of geotransform matrix.
- --skip-metadata
- Whether to skip comparison of metadata
- --skip-overview
- Whether to skip comparison of overviews.
- --skip-rpc
- Whether to skip comparison of Rational Polynomial Coefficients (RPC) metadata domain.
- --skip-subdataset
- Whether to ignore comparison of all subdatasets that are part of the dataset.
STANDARD OPTIONS¶
- --if, --input-format <format>
- 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.
- --oo, --open-option <NAME>=<VALUE>
- Dataset open option (format specific).
May be repeated.
RETURN STATUS CODE¶
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).
EXAMPLES¶
Example 1: Comparing two datasets that differ by their data types¶
$ 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
Example 2: Comparing two datasets while values have different units¶
$ gdal raster pipeline read test_in_foot.tif ! calc --calc "X * 0.3048" ! compare --reference=reference_in_meter.tif
AUTHOR¶
Even Rouault <even.rouault@spatialys.com>
COPYRIGHT¶
1998-2026
| April 15, 2026 |