Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Geometry comparison problems

$
0
0
Hello,

I am having some troubles comparing geometries between two line features and I am wondering if anyone might know a solution.

Basically i would like step through each object in one table and then compare it to a corresponding object in another table to detect if a change has occurred in the geometry of the item.

The problem i am encountering is with the geometry object generated from the "SHAPE@" in the arcpy.da.SearchCursor.
When comparing two pipes that I know are identical, the two geometries return as being not identical to one another, but if i use a "SHAPE@JSON" or simply compare all the XY attributes of the two features, then they do return as being equal as expected.

Has anyone had experience with geometry objects not returning equal when other checks of the same data return being equal?
Further, would simply using "SHAPE@JSON" be a suitable substitute for confirming geometric differences within a pipe?

Thanks for any help!

Here's the code in a nutshell. the mPipes and oPipes are the modified and original features respectivley.

Code:

   
        with arcpy.da.SearchCursor(mPipes,["OID@","SHAPE@","SHAPE@JSON"]) as scursor:
        for row in scursor:
            print row[0]
            expression = '"OBJECTID" = {0}'.format(row[0])
            ogeom = None
            for part in row[1]:
                #row 1 for geometry object, row[2] for json
                mgeom = row[2]
            with arcpy.da.SearchCursor(oPipes,["OID@","SHAPE@","SHAPE@JSON"],where_clause=expression) as check:
                for i in check:
                    for p in i[1]:
                        #i[1] for geometry object, i[2] for json
                        ogeom = i[2]
            if ogeom == mgeom:
                print "Equals!"
            else:
                print "Not Equals!"
            print ogeom
            print mgeom
            print ''


Viewing all articles
Browse latest Browse all 2485

Trending Articles