# Ordering polygon centroid points in a row(s)

I have a image from a field, where I converted the plants to polygons, and then I found the centroid of those polygons (attached image). The numbers displaying on the image are the FID numbers.

I am looking for a way to either create new field on my attribute table showing the ID on the same order showing on the image below or to create a new ID field for each point (starting on the east side and moving to the west, for example).

I tried to sort the data set (around 35,000 points) by X and Y, but I does not work for me, and I assuming that is because I the points are just few inches apart.

My final goal is to measure the distance between each point (not the near distance), such as between 59-60, 60-50, 50-51, 51-33, and so on. Looking around on posts posted on this website, it seems that easier solution for my distance question is calculating them in Excel.

In order to do that I need to have the points in order, so I can calculate the distance to the next point.

I am very familiar with ArcGIS but I am not familiar with Python coding, but I can give a try if I need to.

• Do you have an Advanced license? If so you can sort by the Shape field and set a Spatial Sort Method – Matthew Snape Dec 19 '16 at 17:52
• Is the data consistent with the the gaps in y, so that the vertical distance between rows will always be greater than the horizontal placement between the points? – geoJshaun Dec 19 '16 at 18:17
• This is close to ideal alignment, permitting you to subtract a constant (half again higher than the top row) and divide by the Y gap, then `trunc` the result to populate a row_val column. Sort by row_val (descending) and X value, and your ids write themselves. See gis.stackexchange.com/questions/176197/… – Vince Dec 20 '16 at 1:37

This is close to ideal alignment, permitting you to subtract a constant (half again higher than the top row) and divide by the Y gap, then `trunc` the result to populate a row_val column. Sort by row_val (descending) and X value, and your ids write themselves. See http://gis.stackexchange.com/questions/176197/is-there-a-tool-or-algorithm-for-assigning-a-code-to-enumeration-areas-polygons/176714#176714