I'm using an update cursor to populate some fields which works fine but i want to get the XY of the point at the same time but i get an error:
999999: Error executing function
this is my code:
UpdRPoint = arcpy.UpdateCursor(NearXY_Lyr)
for RP in UpdRPoint:
Desc_1 = RP.getValue("DESCRIPTION_1")
x, y = RP.getValue("SHAPE@XY")
messages.addMessage("{}, {}".format(x, y))
any ideas why its not working?
Solved! Go to Solution.
have you provided the full path to NearXY_Lry somewhere?
Can you print Desc_1?
I would use the newer da.UpdateCursor and acquire the Shape@XY and your other field all at once
UpdateCursor—Data Access module | ArcGIS Desktop
fc = 'c:/full_path_to.gdb/well'
fields = ['DESCRIPTION_1', 'SHAPE@XY']
# Create update cursor for feature class
with arcpy.da.UpdateCursor(fc, fields) as cursor:
for row in cursor:
#do the stuff here
have you provided the full path to NearXY_Lry somewhere?
Can you print Desc_1?
I would use the newer da.UpdateCursor and acquire the Shape@XY and your other field all at once
UpdateCursor—Data Access module | ArcGIS Desktop
fc = 'c:/full_path_to.gdb/well'
fields = ['DESCRIPTION_1', 'SHAPE@XY']
# Create update cursor for feature class
with arcpy.da.UpdateCursor(fc, fields) as cursor:
for row in cursor:
#do the stuff here
thanks Dan that worked a treat
UpdRPoint = arcpy.da.UpdateCursor(NearXY_Lyr, ["DESCRIPTION_1","SHAPE@XY"])
for RP in UpdRPoint:
Desc_1 = RP[0]
x, y = RP[1]
messages.addMessage("{}, {}".format(x, y))