I'm using ArcPy to compare two feature classes from Esri file geodatabases using the Feature Compare (Data Management) tool. The script itself works very well. However it always uses the OBJECTID to perform the comparison.

I am using ArcGIS 10.3.1

import arcpy

    # Set local variables
    test_features = r'myTestFeatureClass'
    base_features = r'myBaseFeatureClass'

    sort_field = "MyCustomID"
    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 = r'C:\data\comparefile.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
    print arcpy.GetMessages()

    # Print error message if an error occurs
    print arcpy.GetMessages()

Does anyone know if there is a way to use a custom ID field for the comparison? In my script I am using "MyCustomID" as a sort parameter. But the result still lists comparisons based on the OBJECTID.

  • 2
    Please specify which version of ArcGIS you are using. You should also edit the question to include the script you're currently using, since it seems that the sort order has a significant impact on how the tool operates. – Vince Sep 16 '15 at 14:52
  • You appear to be using more than one user account. Please use the instructions for merging accounts to do so ASAP. – PolyGeo Sep 17 '15 at 7:12

You could try adding the sort_field(s) to your feature classes then populate the rows with the values of your "MyCustomID" using an update cursor.


The software behaviour that you are observing seems to match the documentation where it says:

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.

If you know the ObjectID and you know the feature class then it is an easy lookup to find the value(s) for any other field(s) that you are interested in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.