I'm using ArcCafe's shiftfeature example and it is working great for shifting the shape. However I want to add an update to one of the attributes and that is not working. Here is my code. The script runs fine and acts like it's working but when I go into the attribute table after running it non of my keynumbers show up...all are still null. What am I doing wrong?
def shift_features(in_features, keynumber, x_shift=None, y_shift=None):
ikeynumber = int(keynumber)
with arcpy.da.UpdateCursor(in_features, ['SHAPE@XY','KEYNUMBER']) as cursor:
for row in cursor:
cursor.updateRow([[row[0][0] + (x_shift or 0),
row[0][1] + (y_shift or 0)], ikeynumber])
return
Solved! Go to Solution.
Hi Priscilla,
Your script looks correct. What type of field is KEYNUMBER?
Try removing the XY update and see if you are able to just update this field. Ex:
def shift_features(in_features, keynumber):
ikeynumber = int(keynumber)
with arcpy.da.UpdateCursor(in_features, ['KEYNUMBER']) as cursor:
for row in cursor:
cursor.updateRow([ikeynumber])
return
Hi Priscilla,
Your script looks correct. What type of field is KEYNUMBER?
Try removing the XY update and see if you are able to just update this field. Ex:
def shift_features(in_features, keynumber):
ikeynumber = int(keynumber)
with arcpy.da.UpdateCursor(in_features, ['KEYNUMBER']) as cursor:
for row in cursor:
cursor.updateRow([ikeynumber])
return