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, it will stop executing after encountering the first miscompare. To report all differences, check on the Continue Comparison parameter.

  • Feature Compare can report differences with geometry, tabular values, spatial reference, and field definitions.

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

  • By default, the compare type is set to All (ALL in Python). This means all properties of the features being compared will be checked, including such things as spatial reference, field properties, attributes, and geometry. However, you may choose a different compare type to check only specific properties of the features being compared.

  • The Ignore Options provide 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. You can choose to ignore these properties. The Ignore extension properties (IGNORE_EXTENSION_PROPERTIES in Python) 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 is determined by the default XY Tolerance of the Input Base Features. To minimize error, the value you choose for the compare tolerance should be as small as possible. If zero is entered for the XY Tolerance, an exact match is performed.

  • The default M Tolerance and the default Z Tolerance is determined by the default M Tolerance and Z Tolerance of the Input Base Features. The units are the same as those of the Input Base Features. If zero is entered for the M Tolerance and Z Tolerance, an exact match is performed.

  • When comparing Geometry only (GEOMETRY_ONLY in Python), the spatial references must match. If the spatial references are different, a miscompare will be reported. If the coordinate system is different for either input, the features will miscompare. This tool does not do projection on the fly.

  • The Omit Fields parameter is a list of fields that are not 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 will contain all similarities and differences between the Input Base Features and the Input Test Features. This file is a comma-delimited text file which can be viewed and used as a table in ArcGIS. For example, this table can be queried to obtain all the ObjectID values for all the rows that are different. The has_error field indicates that the record contains an error. True indicates there is a difference.

  • One of the first comparisons performed is a feature count. If the feature count is reported as being different and the Continue Compare parameter is True, the subsequent comparison messages may not accurately reflect additional differences between the Input Base Features and Input Test Features. This is due to the Feature Compare tool's inability to figure out where features have been added or removed in the Input Test Features and simply moves to the next row in each attribute table. At the location in the attribute table where a feature has been added or deleted, the tool will simply move to the next row and begin comparing the base feature with the wrong test feature because the correct one in the Input Test Data was deleted or a feature was added before it.

  • When using this tool in Python, you can get the status of this tool using result.getOutput(1). The value will be 'true' when no differences are found and 'false' when differences are detected.

    Learn more about using tools in Python

Syntax

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})
ParameterExplanationData Type
in_base_features

The Input Base Features are compared with the Input Test Features. Input Base Features refers to data that you have declared valid. This base data has the correct geometry definitions, field definitions, and spatial reference.

Feature Layer
in_test_features

The Input Test Features are compared against the Input Base Features. Input Test Features refers to data that you have made changes to by editing or compiling new features.

Feature Layer
sort_field
[sort_field,...]

The field or fields used to sort records in the Input Base Features and the Input Test Features. The records are sorted in ascending order. Sorting by a common field in both the Input Base Features and the Input Test Features ensures that you are comparing the same row from each input dataset.

Value Table
compare_type
(Optional)

The comparison type. The default is All, which will compare all properties of the features being compared.

  • 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 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_option,...]
(Optional)

These properties will not be compared.

  • IGNORE_MDo not compare measure properties.
  • IGNORE_ZDo not compare elevation properties.
  • IGNORE_POINTIDDo not compare point ID properties.
  • IGNORE_EXTENSION_PROPERTIESDo not compare extension properties.
  • IGNORE_SUBTYPESDo not compare subtypes.
  • IGNORE_RELATIONSHIPCLASSESDo not compare relationship classes.
  • IGNORE_REPRESENTATIONCLASSESDo not compare representation classes.
  • IGNORE_FIELDALIASDo not compare field aliases.
String
xy_tolerance
(Optional)

The distance that determines the range in which features are considered equal. To minimize error, the value you choose for the compare tolerance 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 measure tolerance is the minimum distance between measures before they are considered equal.

Double
z_tolerance
(Optional)

The Z Tolerance is the minimum distance between z coordinates before they are considered equal.

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

The numeric value that determines the range in which attribute values are considered equal. This 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)

Indicates whether to compare all properties after encountering the first mismatch.

  • NO_CONTINUE_COMPAREStops after encountering the first mismatch. This is the default.
  • CONTINUE_COMPARECompares other properties after encountering the first mismatch.
Boolean
out_compare_file
(Optional)

This file will contain all similarities and differences between the in_base_features and the in_test_features. 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 detected.

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.FeatureCompare_management(
    r'C:/Workspace/baseroads.shp', r'C:/Workspace/newroads.shp', 'ROAD_ID', 
    'ALL', 'IGNORE_M;IGNORE_Z', '0.001 METERS', 0, 0, 'Shape_Length 0.001', '#', 
    'CONTINUE_COMPARE', r'C:/Workspace/roadcompare.txt')
FeatureCompare example 2 (stand-alone script)

Example of how to use the FeatureCompare tool 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.FeatureCompare_management(
    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