Raster Compare (Data Management)

Summary

Compares the properties of two raster or mosaic datasets.

Usage

  • The tool returns messages showing the comparison result.

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

Parameters

LabelExplanationData Type
Input Base Raster

The first raster or mosaic dataset to compare.

Raster Layer; Mosaic Layer
Input Test Raster

The second raster or mosaic dataset to compare with the first.

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.
String
Continue Comparison
(Optional)

Specifies whether the comparison will stop if a mismatch is encountered.

  • Unchecked—The comparison will stop if a mismatch is encountered. This is the default.
  • Checked—The comparison will continue if a mismatch is encountered.
Boolean
Output Compare File
(Optional)

A text file containing the comparison results.

File
Parameter Tolerance
(Optional)

The tolerances that determine the range in which values are 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 set as either a value or a fraction. For example, if the base value is 100 and a fraction tolerance is set to 0.00001, the compare tolerance will be within 100 * 0.001 (100 * 0.00001).

Value Table
Attribute Tolerance
(Optional)

The fields that will be compared to determine if they are within a tolerance. The tolerance value is a value in the units of the attribute.

Value Table
Omit Fields
(Optional)

The field or fields that will be omitted during comparison.

String

Derived Output

LabelExplanationData Type
Compare Status

The compare status will be true if no differences are found; it will be false if 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})
NameExplanationData Type
in_base_raster

The first raster or mosaic dataset to compare.

Raster Layer; Mosaic Layer
in_test_raster

The second raster or mosaic dataset to compare with the first.

Raster Layer; Mosaic Layer
compare_type
(Optional)

Specifies the type of rasters that will be compared.

  • RASTER_DATASETTwo raster datasets will be compared.
  • GDB_RASTER_DATASETTwo raster datasets in a geodatabase will be compared.
  • MOSAIC_DATASETTwo mosaic datasets will be compared.
String
ignore_option
[ignore_option,...]
(Optional)

Specifies the properties that will be ignored in the comparison.

  • BandCountThe number of bands will be ignored.
  • ExtentThe extent will be ignored.
  • Columns And RowsThe number of columns and rows will be ignored.
  • Pixel TypeThe pixel type will be ignored.
  • NoDataThe NoData value will be ignored.
  • Spatial ReferenceThe spatial reference system will be ignored.
  • Pixel ValueThe pixel values will be ignored.
  • ColormapExisting color mas will be ignored.
  • Raster Attribute TableExisting attribute tables will be ignored.
  • StatisticsStatistics will be ignored.
  • MetadataMetadata will be ignored.
  • Pyramids ExistExisting pyramids will be ignored.
  • Compression TypeThe compression type will be ignored.
String
continue_compare
(Optional)

Specifies whether the comparison will stop if a mismatch is encountered.

  • NO_CONTINUE_COMPAREThe comparison will stop if a mismatch is encountered. This is the default.
  • CONTINUE_COMPAREThe comparison will continue if a mismatch is encountered.
Boolean
out_compare_file
(Optional)

A text file containing the comparison results.

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

The tolerances that determine the range in which values are 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 set as either a value or a fraction. For example, if the base value is 100 and a fraction tolerance is set to 0.00001, the compare tolerance will be within 100 * 0.001 (100 * 0.00001).

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

The fields that will be compared to determine if they are within a tolerance. The tolerance value is a value in the units of the attribute.

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

The field or fields that will be omitted during comparison.

String

Derived Output

NameExplanationData Type
compare_status

The compare status will be true if no differences are found; it will be false if differences are found.

Boolean

Code sample

RasterCompare example 1 (Python window)

This is a Python sample for the RasterCompare function.

import arcpy
RasterCompare_management("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.RasterCompare_management("raster_base.tif","raster_test.tif","RASTER_DATASET",\
                                   "","CONTINUE_COMPARE","compareresult.txt","","","")
    
    ##Compare two Raster Catalog with ignore options
    arcpy.RasterCompare_management("fgdb.gdb/rc_base","fgdb.gdb/rc_test","RASTER_CATALOG",\
                                   "IsManaged;Extent","CONTINUE_COMPARE","compareresult2.txt",\
                                   "","","DATE")
    
    ##Compare two Mosaic Dataset with torelance
    arcpy.RasterCompare_management("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