Raster Compare (Data Management)

Summary

Compares the properties of two raster datasets or two mosaic datasets.

Usage

  • The tool returns messages showing the comparison result.

  • The parameter and attribute tolerances allow the comparisons to have a specified amount of deviation.

  • When using this tool in Python, get the status of the comparison from the returned Result object using the index position of 1.(result[1]). The value will be 'true' when no differences are found and 'false' when differences are found.

    Learn more about using tools in Python

Parameters

LabelExplanationData Type
Input Base Raster

The raster or mosaic dataset that will be compared with the Input Test Raster parameter value. This parameter value is data that you have declared valid. This base data has the correct content and information.

Raster Layer; Mosaic Layer
Input Test Raster

The raster or mosaic dataset that will be compared with the Input Base Raster parameter value. This parameter value is data that you have made changes to by editing or compiling new information.

Raster Layer; Mosaic Layer
Compare Type
(Optional)

Specifies the type of rasters that will be compared.

  • Raster dataset—Two raster datasets will be compared.
  • Geodatabase raster dataset—Two raster datasets in a geodatabase will be compared.
  • Mosaic dataset—Two mosaic datasets will be compared.
String
Ignore Options
(Optional)

Specifies the properties that will be ignored in the comparison.

  • Band count—The number of bands will be ignored.
  • Extent—The extent will be ignored.
  • Columns and rows—The number of columns and rows will be ignored.
  • Pixel type—The pixel type will be ignored.
  • NoData—The NoData value will be ignored.
  • Spatial reference—The spatial reference system will be ignored.
  • Pixel value—The pixel values will be ignored.
  • Colormap—Existing color maps will be ignored.
  • Raster attribute table—Existing attribute tables will be ignored.
  • Statistics—Statistics will be ignored.
  • Metadata—Metadata will be ignored.
  • Pyramids exist—Existing pyramids will be ignored.
  • Compression type—The compression type will be ignored.
  • Data source type—The data source type will be ignored.
String
Continue Comparison
(Optional)

Specifies whether the comparison will continue after encountering the first difference between the inputs.

  • Unchecked—The tool will stop after encountering the first difference. This is the default.
  • Checked—The tool will continue after encountering the first difference.

Boolean
Output Compare File
(Optional)

The output file that will contain all similarities and differences between the inputs. This file is a comma-delimited text file that can be viewed and used as a table in ArcGIS.

The output file that will contain all similarities and differences between the inputs. This file is a comma-delimited text file that can be viewed and used as a table in ArcGIS.

File
Parameter Tolerance
(Optional)

The tolerances that determine the range in which values will be considered equal. The same tolerance can be applied to all parameters, or different tolerances can be applied to individual parameters.

The tolerance type can be either a value or a fraction.

If the tolerance type is a fraction, the tolerance for each pixel will be different since each pixel has a different value. For example, if a tolerance fraction is set to 0.5, the tolerance will be calculated as follows:

  • If a pixel has a value of 0.2, the tolerance will be 0.1, since 0.5 * 0.2 = 0.1.
  • If a pixel has a value of 3, the tolerance will be 1.5, since 0.5 * 3 = 1.5.

Value Table
Attribute Tolerance
(Optional)

The numeric value that will determine the range in which attribute values are considered equal. This parameter only applies to numeric field types.

Value Table
Omit Fields
(Optional)

The field or fields that will be omitted during comparison. The field definitions and the tabular values for these fields will be ignored.

String
Out Compare Raster
(Optional)

The output raster comprising the differences between the Input Base Raster and Input Test Raster parameter values.

Raster Dataset

Derived Output

LabelExplanationData Type
Compare Status

The compare status will be 'true' when no differences are found and 'false' when differences are found.

Boolean

arcpy.management.RasterCompare(in_base_raster, in_test_raster, {compare_type}, {ignore_option}, {continue_compare}, {out_compare_file}, {parameter_tolerances}, {attribute_tolerances}, {omit_field}, {out_compare_raster})
NameExplanationData Type
in_base_raster

The raster or mosaic dataset that will be compared with the in_test_raster parameter value. This parameter value is data that you have declared valid. This base data has the correct content and information.

Raster Layer; Mosaic Layer
in_test_raster

The raster or mosaic dataset that will be compared with the in_base_raster parameter value. This parameter value is data that you have made changes to by editing or compiling new information.

Raster Layer; Mosaic Layer
compare_type
(Optional)

Specifies the type of rasters that will be compared.

  • RASTER_DATASET—Two raster datasets will be compared.
  • GDB_RASTER_DATASET—Two raster datasets in a geodatabase will be compared.
  • MOSAIC_DATASET—Two mosaic datasets will be compared.
String
ignore_option
[ignore_option,...]
(Optional)

Specifies the properties that will be ignored in the comparison.

  • BandCount—The number of bands will be ignored.
  • Extent—The extent will be ignored.
  • Columns And Rows—The number of columns and rows will be ignored.
  • Pixel Type—The pixel type will be ignored.
  • NoData—The NoData value will be ignored.
  • Spatial Reference—The spatial reference system will be ignored.
  • Pixel Value—The pixel values will be ignored.
  • Colormap—Existing color maps will be ignored.
  • Raster Attribute Table—Existing attribute tables will be ignored.
  • Statistics—Statistics will be ignored.
  • Metadata—Metadata will be ignored.
  • Pyramids Exist—Existing pyramids will be ignored.
  • Compression Type—The compression type will be ignored.
  • Data Source Type—The data source type will be ignored.
String
continue_compare
(Optional)

Specifies whether the comparison will continue after encountering the first difference between the inputs.

  • NO_CONTINUE_COMPARE—The tool will stop after encountering the first difference. This is the default.
  • CONTINUE_COMPARE—The tool will continue after encountering the first difference.
Boolean
out_compare_file
(Optional)

The output file that will contain all similarities and differences between the inputs. This file is a comma-delimited text file that can be viewed and used as a table in ArcGIS.

File
parameter_tolerances
[[Parameter, Tolerance, Type],...]
(Optional)

The tolerances that determine the range in which values will be considered equal. The same tolerance can be applied to all parameters, or different tolerances can be applied to individual parameters.

The tolerance type can be either a value or a fraction.

If the tolerance type is a fraction, the tolerance for each pixel will be different since each pixel has a different value. For example, if a tolerance fraction is set to 0.5, the tolerance will be calculated as follows:

  • If a pixel has a value of 0.2, the tolerance will be 0.1, since 0.5 * 0.2 = 0.1.
  • If a pixel has a value of 3, the tolerance will be 1.5, since 0.5 * 3 = 1.5.

Value Table
attribute_tolerances
[[Field, {Tolerance}],...]
(Optional)

The numeric value that will determine the range in which attribute values are considered equal. This parameter only applies to numeric field types.

Value Table
omit_field
[omit_field,...]
(Optional)

The field or fields that will be omitted during comparison. The field definitions and the tabular values for these fields will be ignored.

String
out_compare_raster
(Optional)

The output raster comprising the differences between the in_base_raster and in_test_raster parameter values.

Raster Dataset

Derived Output

NameExplanationData Type
compare_status

The compare status will be 'true' when no differences are found and 'false' when differences are found.

Boolean

Code sample

RasterCompare example 1 (Python window)

This is a Python sample for the RasterCompare function.

import arcpy
arcpy.management.RasterCompare("C:/workspace/image1.tif","C:/workspace/image2.tif",
                         "RASTER_DATASET","'Pyramids Exist'",
                         "CONTINUE_COMPARE","C:/workspace/compare01.txt",
                         "Pixel_Value 1 Value","Count 5","OID")
RasterCompare example 2 (stand-alone script)

This is a Python sample for the RasterCompare function.

##====================================
##Raster Compare
##Usage: RasterCompare_management in_base_raster in_test_raster {RASTER_DATASET |
##                                GDB_RASTER_DATASET | GDB_RASTER_CATALOG |
##                                MOSAIC_DATASET} {ignore_option;ignore_option...}
##                                {NO_CONTINUE_COMPARE | CONTINUE_COMPARE}
##                                {out_compare_file} {Parameter {Tolerance} {Type};
##                                Parameter {Tolerance} {Type}...} {Field {Tolerance};
##                                Field {Tolerance}...} {omit_field;omit_field...}


try:
    import arcpy

    arcpy.env.workspace = "c:/workspace"

    ##Compare two Raster dataset
    arcpy.management.RasterCompare("raster_base.tif","raster_test.tif","RASTER_DATASET",
                                   "","CONTINUE_COMPARE","compareresult.txt","","","")

    ##Compare two Raster Catalog with ignore options
    arcpy.management.RasterCompare("fgdb.gdb/rc_base","fgdb.gdb/rc_test","RASTER_CATALOG",
                                   "IsManaged;Extent","CONTINUE_COMPARE","compareresult2.txt",
                                   "","","DATE")

    ##Compare two Mosaic Dataset with torelance
    arcpy.management.RasterCompare("fgdb.gdb/md_base","fgdb.gdb/md_test","MOSAIC_DATASET",
                                   "IsEmbedded;Seamline","CONTINUE_COMPARE","compareresult3.txt",
                                   "All 0.00001 Fraction","HighPS 0.0001;LowPS 0.0001",
                                   "ItemTS;UriHash")

except:
    print("Raster Compare exsample failed.")
    print(arcpy.GetMessages())

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics