1

I am trying to update the geometry of a point FC stored in a FileGeodatabase using ArcPy.

I got this Python script to compare the values of the SHAPE@X and SHAPE@Y and change the Geometry if not equal to the values stored in the attribute table (X_UTM_WGS84, Y_UTM_WGS84).

Even if I edit the feature and remove the extra digits past the second digit I get this when I print the values: I do not understand why the values are different ???

***** CODE USED:

2015-02-26_Compare_Geometry_With_Table_XY.py Compare the Geometry of points using the table values

import arcpy

fc = "D:/DATA_2014.gdb/UTM/TEST_PROJECTION_PT"
fields = ('SHAPE@X', 'SHAPE@Y', 'X_UTM_WGS84', 'Y_UTM_WGS84', 'POINT_NAME')

 Create search cursor for feature class 

i=0
with arcpy.da.SearchCursor(fc, fields) as cursor:
    for row in cursor:  # row[4]+ POINT NAME OUT OF PRINT
        i+=1
        print 'POINT ---> ' + str(i)
        print '\tSHAPE@X= ' + "%.11f" % round(row[0],11) + ' X_UTM_WGS84 = ' + "%.11f" % round(row[2],11) + ' EQUAL= ' + str(row[0] == row[2]) + ' DIFF= ' + str(row[0] -row[2])
        print '\tSHAPE@Y= ' + "%.11f" % round(row[1],11) + ' Y_UTM_WGS84 = ' + "%.11f" % round(row[3],11) + ' EQUAL= ' + str(row[1] == row[3]) + ' DIFF= ' + str(row[1] -row[3])

del cursor, row
print '\t\tEND....'

***** RESULTS:


POINT ---> 1
    SHAPE@X= 460965.17999999970 X_UTM_WGS84 = 460965.17999999970 EQUAL= True DIFF= 0.0
    SHAPE@Y= 1288230.55000000075 Y_UTM_WGS84 = 1288230.55000000005 EQUAL= False DIFF= 6.98491930962e-10
POINT ---> 2
    SHAPE@X= 413207.26999999955 X_UTM_WGS84 = 413207.26999999955 EQUAL= True DIFF= 0.0
    SHAPE@Y= 1382676.34999999963 Y_UTM_WGS84 = 1382676.34999999963 EQUAL= True DIFF= 0.0
POINT ---> 3
    SHAPE@X= 433224.66000000015 X_UTM_WGS84 = 433224.65999999997 EQUAL= False DIFF= 1.7462298274e-10
    SHAPE@Y= 1363812.55000000075 Y_UTM_WGS84 = 1363812.55000000005 EQUAL= False DIFF= 6.98491930962e-10
POINT ---> 4
    SHAPE@X= 428742.87000000011 X_UTM_WGS84 = 428742.87000000000 EQUAL= False DIFF= 1.16415321827e-10
    SHAPE@Y= 1233218.47000000067 Y_UTM_WGS84 = 1233218.46999999997 EQUAL= False DIFF= 6.98491930962e-10
POINT ---> 5
    SHAPE@X= 407040.38999999966 X_UTM_WGS84 = 407040.39000000001 EQUAL= False DIFF= -3.49245965481e-10
    SHAPE@Y= 1227264.44999999925 Y_UTM_WGS84 = 1227264.44999999995 EQUAL= False DIFF= -6.98491930962e-10
POINT ---> 6
    SHAPE@X= 403344.58999999985 X_UTM_WGS84 = 403344.59000000003 EQUAL= False DIFF= -1.7462298274e-10
    SHAPE@Y= 1250201.60999999940 Y_UTM_WGS84 = 1250201.61000000010 EQUAL= False DIFF= -6.98491930962e-10
POINT ---> 7
    SHAPE@X= 420615.79999999981 X_UTM_WGS84 = 420615.79999999981 EQUAL= True DIFF= 0.0
    SHAPE@Y= 1249885.83999999985 Y_UTM_WGS84 = 1249885.83999999985 EQUAL= True DIFF= 0.0
        END....
3

Those coordinate differences are measured in Angstroms.

File geodatabase uses a technique similar to the integer storage representation conversion in enterprise geodatabases (ArcSDE) to snap 64-bit floating-point coordinate values to a feature class coordinate resolution grid. This coordinate resolution is established at feature class creation (and it's usually on the order of millimeters, not 6 orders of magnitude smaller). Your feature class appears to have been created at centimeter (1.0e-02 m) resolution.

The differences you are seeing are artifacts of rounding at the far edge of mantissa storage in IEEE 64-bit floating-point representation. If you want to do floating-point value comparison, you need to be prepared to apply a "within" tolerance, or convert to integers at some scale factor (which is what FGDB is doing).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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