0

I am trying to compare the fields of 2 feature layers to each other. The fields, though, have different names. I think this image shows this a little better:

enter image description here

I am lost as to how this can be accomplished. I am trying to compare modified's FIELD2 to baseline's FIELD1, etc.

While I am sure that I will need arcpy.FieldMappings, I wrote these few lines:

baseline_copy_path = os.path.join(self.tempPath ,"baseline_copy.shp")
fieldmappings = arcpy.FieldMappings()
fieldmappings.addTable(self.revisedFile)
fieldmappings.addTable(baseline_copy_path)

At this point, I am unsure how to proceed.

I am looking for help in finding example code doing this or somebody who might outline how to proceed. At the end of the comparison, I am looking to produce a DEFeatureClass for each of these: new features in the modified file, deletions, overlapping features, changed attributes in modified fiel and finally, removed features. The changes I am looking for are in the geometries.

asked Oct 11, 2016 at 14:16
4
  • What are you trying to compare? The values between field pairs for a given value in a third field (e.g., geometry, ID)? The field properties (e.g., type, length)? Commented Oct 11, 2016 at 14:27
  • Tom, I've added the following to the question: "At the end of the comparison, I am looking to produce a DEFeatureClass for each of these: new features in the modified file, deletions, overlapping features, changed attributes in modified field and finally, removed features. The changes I am looking for are in the geometries." Commented Oct 11, 2016 at 14:40
  • You can perform a Spatial Join then create your specific Where Clause for Select By Attribute, Field1 <> Field2 or Field2 <> Field3, etc Commented Oct 11, 2016 at 15:00
  • 2
    Do you have non geometry field to join on? Commented Oct 11, 2016 at 18:27

1 Answer 1

3

You should start with a simple Union. Just be aware of two details described on that page: 1) how ESRI renames fields when unioned feature classes share field names; 2) the FID_ fields that ESRI creates during a union and how to use them. With that knowledge, it's really simple to query out the various things you're looking for.

From your example above, here are some example queries:

  1. To query spatial areas that were covered by baseline but not by modified: FID_modified = -1

  2. To query spatial areas that were added in modified but were not covered by baseline: FID_baseline = -1

  3. To query areas where the value of FIELD1 (now renamed to FIELD2) has changed: FIELD1 <> FIELD2

Note that examples one and two won't necessarily identify "deleted" or "added" features. For that, it's best to use Editor Tracking. Otherwise, you can't really determine whether something is the same feature or another feature with the same attributes in the same location. If that's okay with you, then something like:

FID_baseline <> -1 
AND FID_modified <> -1
AND (FIELD1 <> FIELD2_1 
 OR FIELD2 <> FIELD3_1 
 OR FIELD3 <> FIELD1_1 
 OR FIELD4 <> FIELD6)

That would query features that have at least one altered value at that location.

Note that the benefit of Union over something like Spatial Join is that Union can pull out the portions of features that have changes--in the case that geometries have been changed.

EDIT: If you're using points/lines, please don't. Points, lines, and polygons don't exist in our 3-dimensional (spatially speaking) universe, and using points and lines results in misrepresentations of data that will come back to bite you. Polygons are also a tragic compromise, but the limitations of the available tools constrain much GIS work to 2-dimensions. However, if you are using points/lines, then you could use some convoluted chain of Intersect, Erase, and Append to yield a result that is comparable to Union.

answered Oct 11, 2016 at 15:27
3
  • What is going to happen if inputs are not polygons? Moreover it is not going to work for polygons either. -1 BTW for solution that has nothing to do with the question. Commented Oct 11, 2016 at 20:31
  • @FelixIP, what do you mean has nothing to do with the question? The data model image includes no UID in either dataset. Read the last sentence in the OP's edit: he's looking for changes by geometry. I take this to mean that if an area was covered by a FIELD1 value of 4 and that area is now covered by a FIELD2_1 value of 4, then it has not changed. My answer would identify that. His sentence could be interpreted as he's looking for changes to the geometry of a given feature, but considering he apparently has no UID, that's impossible and I, therefore, assumed not what he's asking. Commented Oct 11, 2016 at 20:47
  • You rephrase your answer, I remove my down vote. Union tool will no accept other geometries, but polygons Commented Oct 11, 2016 at 22:55

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.