I have a huge number of shape files that I receive on a recurring basis. I want to be able to compare the new version to the current version, and then only update the db with those that are different.
Currently, I am using arcpy.FeatureCompare_management to check Geometry & Attributes. However, this seems to be quite timely. I was considering if a byte-by-byte comparison of the .shp and .dbf files would work, but I run into discrepencies? This is what I have tried so far:
# These refer to the FQP of the Geometry and Attribute files for the same data-sourceold_geo_file = r'\myfiles\q1\myshape.shp'new_geo_file = r'\myfiles\q2\myshape.shp'# These are only needed by filecmp. ArcPy grabs related files.old_attr_file = r'\myfiles\q1\myshape.dbf'new_attr_file = r'\myfiles\q2\myshape.dbf'arcpy_geo = arcpy.FeatureCompare_management(new_geo_file, old_geo_file, 'MY_SORT_COL', 'GEOMETRY_ONLY')arcpy_attr = arcpy.FeatureCompare_management(new_geo_file, old_geo_file, 'MY_SORT_COL', 'ATTRIBUTES_ONLY')print arcpy_geoprint arcpy_attrprint('*' * 10)# Clear the filecmp cache to ensure comparisonfilecmp._cache = {}filecmp_geo = filecmp.cmp(new_geo_file, old_geo_file, shallow=False)filecmp_attr = filecmp.cmp(new_attr_file, old_attr_file, shallow=False)print filecmp_geoprint filecmp_attrThis is the output:
TrueFalse**********FalseFalseCan someone explain why a byte comparison would come out False, but ArcPy still considers them geometrically the same?
أكثر...
Currently, I am using arcpy.FeatureCompare_management to check Geometry & Attributes. However, this seems to be quite timely. I was considering if a byte-by-byte comparison of the .shp and .dbf files would work, but I run into discrepencies? This is what I have tried so far:
# These refer to the FQP of the Geometry and Attribute files for the same data-sourceold_geo_file = r'\myfiles\q1\myshape.shp'new_geo_file = r'\myfiles\q2\myshape.shp'# These are only needed by filecmp. ArcPy grabs related files.old_attr_file = r'\myfiles\q1\myshape.dbf'new_attr_file = r'\myfiles\q2\myshape.dbf'arcpy_geo = arcpy.FeatureCompare_management(new_geo_file, old_geo_file, 'MY_SORT_COL', 'GEOMETRY_ONLY')arcpy_attr = arcpy.FeatureCompare_management(new_geo_file, old_geo_file, 'MY_SORT_COL', 'ATTRIBUTES_ONLY')print arcpy_geoprint arcpy_attrprint('*' * 10)# Clear the filecmp cache to ensure comparisonfilecmp._cache = {}filecmp_geo = filecmp.cmp(new_geo_file, old_geo_file, shallow=False)filecmp_attr = filecmp.cmp(new_attr_file, old_attr_file, shallow=False)print filecmp_geoprint filecmp_attrThis is the output:
TrueFalse**********FalseFalseCan someone explain why a byte comparison would come out False, but ArcPy still considers them geometrically the same?
أكثر...