4

What is the most efficient method for determining if two features (points, lines, or polygons) are geometrically identical? I'm not concerned about a square figure that contains eight vertices (four corners and vertices at segment midpoints) being flagged as identical to a "true" square (four corners and no vertices at segment midpoints).

Potential gotchas are the order of the vertices and direction of line or polygon. Suppose one square is defined starting in the northwest corner and another square starts in the southeast. Coordinates of the vertices and all other properties are identical. I would expect these to be a match since just the order of vertices is just different. Or what if one square is defined clockwise but the other counter-clockwise? Again, this shouldn't matter.

What is the most efficient way to find if the two are identical?

2 Answers 2

5

Use the geometry object's equals method. With polygons and polylines, if their symmetric difference is empty they are considered equal.

So for example, in the below, g2 is the same as g1, it just has an extra vertex in the middle, and g3 is opposite to g1, so always equal.

>>> g1 = arcpy.Polyline(arcpy.Array([arcpy.Point(1, 1), arcpy.Point(3, 3)]))
>>> g2 = arcpy.Polyline(arcpy.Array([arcpy.Point(1, 1), arcpy.Point(2, 2), arcpy.Point(3, 3)]))
>>> g3 = arcpy.Polyline(arcpy.Array([arcpy.Point(3, 3), arcpy.Point(1, 1)]))
>>> g1.equals(g2)
True
>>> g1.equals(g3)
True
>>> g2.equals(g3)
True
4

You can use Find Identical, using the geometry of the features.

Alternately, you can spatially join a feature class to itself, and use the "ARE_IDENTICAL_TO" as your match option. This can be useful if you have a bunch of features stacked on top of each other and you want to deduplicate (features with a Join_Count > 1). I recently used this to clean up some parcel data where someone had just copy-and-pasted parcels in-place and edited the attributes of the new feature instead of just editing the existing parcel.

Your Answer

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

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