I have a lot of points. In the attribute table I have the coordinates(coordx / coordy).
How can I move all points, so that they are corresponding to the coordinates value in the attribute table?
I have a lot of points. In the attribute table I have the coordinates(coordx / coordy).
How can I move all points, so that they are corresponding to the coordinates value in the attribute table?
You may do this within field calculator, see blog:
How to Update the Location of a Point Feature and Its XY Fields
def XYsetVALUE( shape, X_value, Y_value):
point = shape.getPart(0)
point.X = X_value
point.Y = Y_value
return point
__esri_field_calculator_splitter__
XYsetVALUE ( !SHAPE!, !X_COORD!, !Y_COORD! )
One way to do it is to use the UpdateCursor in the Python Window. Be sure to backup your data before executing:
import arcpy
feature_class=r'C:\TEST.gdb\points' #Change path and name to fc
fieldlist=['X_field','Y_field'] #Change field names to match your data
tokens=['SHAPE@X','SHAPE@Y']
with arcpy.da.UpdateCursor(feature_class,fieldlist+tokens) as cursor:
for row in cursor:
row[2]=row[0] #Set row[2], which is SHAPE@X, to the value of row[0] which is the first field in fieldlist
row[3]=row[1]
cursor.updateRow(row)