# Creating Unique IDs of points in order from west to east

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?

• Calculate new field xcoordinate > sort by xcoordinate > add new numeric field "seq" > fill field seq with counter see: gis.stackexchange.com/questions/193681/… Dec 7, 2020 at 20:45
• A simple sort on easting and northing (descending) should work for this, though you might get more methodical results with large datasets if you use a grid to bin values first. See gis.stackexchange.com/questions/73978/… Dec 7, 2020 at 21:45
• Dec 7, 2020 at 22:30
• The solution in the link takes into account `OID` order, I guess. Dec 7, 2020 at 23:46
• The `Sort (management)` gp tool will produce a sorted fc. You can set the sorting to be from left to right (cartesian). Then use the `Create sequential number using Calc Field` as stated above. Dec 18, 2020 at 0:29

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")]
x_values.sort(reverse=True)

global x_values
i = x_values.index(x)
return i
``````
• And call the method.

``````add_unique_ids(!POINT_X!)
``````

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

• 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
• 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. 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