Feature Compare (Data Management)

Summary

Compares two feature classes or layers and returns the comparison results.

Usage

  • This tool returns messages showing the comparison result. By default, the tool will stop running after encountering the first difference between the inputs. To report all differences, check the Continue Comparison parameter.

  • If the differences reported between the input datasets are due to the addition or deletion of records, only the first reported difference is valid. All reported differences after the addition or deletion will be due to the comparison being out of sequence. The compare tools do not attempt to find the next set of matching records after an added or deleted record is encountered.

  • This tool can report differences in geometry, tabular values, spatial reference, and field definitions.

  • Multiple sort fields can be specified. The first field is sorted, the second field is sorted, and so on, in ascending order. Sorting by a common field in both input datasets ensures that you are comparing the same row from each input dataset.

  • By default, the Compare Type parameter is set to All. This means all properties of the features being compared will be checked, including the spatial reference, field properties, attributes, and geometry. Specify a different compare type to compare specific properties of the features.

  • The Ignore Options parameter provides the flexibility to omit properties such as measure attributes, z-attributes, point ID attributes, and extension properties. Two feature classes may be identical, yet one has measures and z-coordinates and the other does not. The Ignore extension properties option refers to additional information added to a feature class or table. For example, the features of two annotation feature classes can be identical, but the feature classes may have different extension properties, such as different symbols in the symbol collection and different editing behavior.

  • The default XY Tolerance parameter value is determined by the default xy-tolerance of the Input Base Features parameter value. To minimize error, the value used for the compare tolerance should be as small as possible. If a value of 0 is specified, an exact match will be performed.

  • The default M Tolerance and Z Tolerance parameter values are determined by the default m-tolerance and z-tolerance of the Input Base Features parameter value. The units are the same as those of the Input Base Features parameter value. If a value of 0 is specified, an exact match will be performed.

  • When using the Geometry only option for the Compare Type parameter, the spatial references must match. If the spatial references for the inputs are not the same, a difference between the inputs will be reported. If the coordinate systems for the inputs are not the same, the features will be considered different. This tool does not project features on the fly.

  • The Omit Fields parameter is a list of fields that will not be included in the field count comparison—their field definitions and tabular values are ignored.

  • Attribute tolerances can only be specified for numeric field types.

  • The Output Compare File parameter value will contain all similarities and differences between the input datasets. This file is a comma-delimited text file that can be viewed and used as a table in ArcGIS. For example, it can be queried to obtain all the object ID values for all the rows that are different. The has_error field indicates that the record contains an error. A value of True indicates a difference.

  • 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 Features

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

Feature Layer
Input Test Features

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

Feature Layer
Sort Field

The field or fields that will be used to sort records in the inputs. The records are sorted in ascending order. Sorting by a common field in both inputs ensures that you are comparing the same row from each input dataset.

Value Table
Compare Type
(Optional)

Specifies the comparison type that will be used.

  • AllAll properties of the feature classes will be compared. This is the default.
  • Geometry onlyOnly the geometries of the feature classes will be compared.
  • Attributes onlyOnly the attributes and their values of the feature classes will be compared.
  • Schema onlyOnly the schema of the feature classes will be compared.
  • Spatial Reference onlyOnly the spatial references of the two feature classes will be compared.
String
Ignore Options
(Optional)

Specifies the properties that will not be compared.

  • Ignore MsMeasure properties will not be compared.
  • Ignore ZsElevation properties will not be compared.
  • Ignore PointIDsPoint ID properties will not be compared.
  • Ignore extension propertiesExtension properties will not be compared.
  • Ignore subtypesSubtypes will not be compared.
  • Ignore relationship classesRelationship classes will not be compared.
  • Ignore representation classesRepresentation classes will not be compared.
  • Ignore field aliasField aliases will not be compared.
String
XY Tolerance
(Optional)

The distance that will determine the range in which features will be considered equal. To minimize error, the parameter value should be as small as possible. By default, the compare tolerance is the xy-tolerance of the input base features.

Linear Unit
M Tolerance
(Optional)

The minimum distance between measures before they will be considered equal.

Double
Z Tolerance
(Optional)

The minimum distance between z-coordinates before they will be considered equal.

Double
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
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

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.FeatureCompare(in_base_features, in_test_features, sort_field, {compare_type}, {ignore_options}, {xy_tolerance}, {m_tolerance}, {z_tolerance}, {attribute_tolerances}, {omit_field}, {continue_compare}, {out_compare_file})
NameExplanationData Type
in_base_features

The data that will be compared with the in_test_features parameter value. This parameter value is data that you have declared valid. This base data has the correct content and information.

Feature Layer
in_test_features

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

Feature Layer
sort_field
[sort_field,...]

The field or fields that will be used to sort records in the inputs. The records are sorted in ascending order. Sorting by a common field in both inputs ensures that you are comparing the same row from each input dataset.

Value Table
compare_type
(Optional)

Specifies the comparison type that will be used.

  • ALLAll properties of the feature classes will be compared. This is the default.
  • GEOMETRY_ONLYOnly the geometries of the feature classes will be compared.
  • ATTRIBUTES_ONLYOnly the attributes and their values of the feature classes will be compared.
  • SCHEMA_ONLYOnly the schema of the feature classes will be compared.
  • SPATIAL_REFERENCE_ONLYOnly the spatial references of the two feature classes will be compared.
String
ignore_options
[ignore_options,...]
(Optional)

Specifies the properties that will not be compared.

  • IGNORE_MMeasure properties will not be compared.
  • IGNORE_ZElevation properties will not be compared.
  • IGNORE_POINTIDPoint ID properties will not be compared.
  • IGNORE_EXTENSION_PROPERTIESExtension properties will not be compared.
  • IGNORE_SUBTYPESSubtypes will not be compared.
  • IGNORE_RELATIONSHIPCLASSESRelationship classes will not be compared.
  • IGNORE_REPRESENTATIONCLASSESRepresentation classes will not be compared.
  • IGNORE_FIELDALIASField aliases will not be compared.
String
xy_tolerance
(Optional)

The distance that will determine the range in which features will be considered equal. To minimize error, the parameter value should be as small as possible. By default, the compare tolerance is the xy-tolerance of the input base features.

Linear Unit
m_tolerance
(Optional)

The minimum distance between measures before they will be considered equal.

Double
z_tolerance
(Optional)

The minimum distance between z-coordinates before they will be considered equal.

Double
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
continue_compare
(Optional)

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

  • NO_CONTINUE_COMPAREThe tool will stop after encountering the first difference. This is the default.
  • CONTINUE_COMPAREThe 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

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

FeatureCompare example 1 (Python window)

The following Python window script demonstrates how to use the FeatureCompare function in immediate mode.

import arcpy
arcpy.management.FeatureCompare(
    'C:/Workspace/baseroads.shp', 'C:/Workspace/newroads.shp', 'ROAD_ID', 
    'ALL', ['IGNORE_M', 'IGNORE_Z'], '0.001 METERS', 0, 0,
    [['Shape_Length', 0.001]], '#', 'CONTINUE_COMPARE',
    'C:/Workspace/roadcompare.txt')
FeatureCompare example 2 (stand-alone script)

The following example demonstrates how to use the FeatureCompare function in a stand-alone script.

# Name: FeatureCompare.py
# Description: Compare two feature classes and return comparison result.

# Import system modules 
import arcpy

# Set local variables
base_features = "C:/Workspace/baseroads.shp"
test_features = "C:/Workspace/newroads.shp"
sort_field = "ROAD_ID"
compare_type = "ALL"
ignore_option = ["IGNORE_M", "IGNORE_Z"]
xy_tolerance = "0.001 METERS"
m_tolerance = 0
z_tolerance = 0
attribute_tolerance = [["Shape_Length", 0.001]]
omit_field = "#"
continue_compare = "CONTINUE_COMPARE"
compare_file = "C:/Workspace/roadcompare.txt"
 
# Process: FeatureCompare
compare_result = arcpy.management.FeatureCompare(
    base_features, test_features, sort_field, compare_type, ignore_option, 
    xy_tolerance, m_tolerance, z_tolerance, attribute_tolerance, omit_field, 
    continue_compare, compare_file)

print(compare_result[1])
print(arcpy.GetMessages())

Environments

This tool does not use any geoprocessing environments.

Licensing information

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

Related topics