I'm working on a little arcpy script to compare the geometry of features (linked by a matching ID field
I've got a couple of search cursors populating dictionaries for the two feature classes which I then am trying to compare to find where features (that should be identical shapes) don't match.
I have run into a snag in my concept though in that the output from SHAPE@
is returning False
when I compare the features I know are identical (should return True
).
import arcpy
fields = ['LineID', 'SHAPE@']
x = 'Line1' # Feature Class #1
y = 'Line2' # Feature Class #2
xDict = dict()
yDict = dict()
with arcpy.da.SearchCursor(x, fields) as cursor:
for row in cursor:
xDict[row[0]] = row[1]
with arcpy.da.SearchCursor(y, fields) as cursor:
for row in cursor:
yDict[row[0]] = row[1]
When I test I get False
returned:
xDict[1] == yDict[1]
> False
This returns False
even though I know that record #1 is identical in both feature classes.
Is there another way I can use my search cursors to compare the shape of the two features? I know there are .WKB
, .WKT
, .JSON
options for Shape - are these valid options for a comparison? My brief testing suggests they are, but I'm unsure whether there are occasions where they would also return False
.
xDict[1].WKB == yDict[1].WKB
> True
xDict[1].equals(yDict[1]) # Should be True
> True
xDict[2].equals(yDict[2]) # Should be False
> True
xDict[4].equals(yDict[4]) # Should be False
> False
equals
operator.equals
operator do you meanxDict[1] is yDict[1]
? This also returnsFalse
shape1.equals(shape2)
True
even for one of the features that should returnFalse
(although it does returnFalse
for another feature correctly)