I have a dataset with over 1000s points. I am wondering if I am able to give each point a unique ID starting from west to east.

I am using ArcMap 10.6. Is there a way to do this in ArcMap?


1 Answer 1


First, to be sure POINT_X has no duplicate values, run next two lines in Python console.

# change layer_name
x_values = [row[0] for row in arcpy.da.SearchCursor("layer_name", "POINT_X")]
len(x_values) == len(set(x_values)) # output should be True

If POINT_X has no duplicate values you can use the following script in Field Calculator.

  • Open Field Calculator (by right click on seq field)

  • Populate the parameters as in the image using the following script. (Don't forget to change layer_name in the script)

    x_values = [row[0] for row in arcpy.da.SearchCursor("layer_name", "POINT_X")]
    def add_unique_ids(x):
        global x_values   
        i = x_values.index(x)   
        return i
  • And call the method.


enter image description here

The main limitation is that features with the same POINT_X get the same seq value. I couldn't figure it out yet.

enter image description here

  • I'm not sure. Give it a try. I have set seq as integer. Dec 8, 2020 at 0:06
  • Yes. I've tried something for duplicate values but I couldn't solve. Dec 8, 2020 at 0:09
  • I got that error. Make sure you typed the layer and field names in SearchCursor. Dec 8, 2020 at 0:20
  • 1
    I think this is related to the data resolution, i.e., number of digits of X coordinate that you receive from ArcGIS and how they are saved in a python list. As a workaround, you can use round builtin function of python. In this answer, if you change row[0] to round(row[0], 4) and x_values.index(x) to x_values.index(round(x ,4)), you would be fine. Here, the value of 4 is arbitrary and presumed it will work in a projected CS.
    – fatih_dur
    Dec 8, 2020 at 0:32
  • I thought that. In your case, it would be fine. But it may return incorrect results for geographic coordinates. Dec 8, 2020 at 0:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.