mikehjun

If Else for Feature Compare or detect changes between two FC

Discussion created by mikehjun on Feb 24, 2011
My overall goal is simple. If there is any differency between two feature classes includiing tabular and geomtry, then copy FC to other place. I found feature compare tool and it does what I need but it just creates the final result in text file. Is there any way I can write if there is any word called 'true' in the final result txt, then copy it. Or is there any other way to detect changes?

Thanks,


Result in text file;
Has_error, Identifier, Message, Base_value, Test_value, ObjectID
"true", "FeatureClass", "ObjectID 8 is different for Field TLID", "123455", "NEW RECORD", 8
"false", "Table", "Table row counts are the same", " ", " ", -1




# FeatureCompare.py
# Description: Compare two feature classes and return comparison result.
# Requirements: None
# Author: ESRI
# Date: 06/21/05

# Create the Geoprocessing Object
import arcgisscripting, sys, os
gp = arcgisscripting.create()

try:
    # 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 = gp.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 gp.GetMessages()

except:
    # Print error message if an error occurs
    print gp.GetMessages()

Outcomes