I would like to number the shown grid of polygons. The numbers should go left to right top to bottom, starting at 1.
How do I do this using ArcGIS Desktop with a Basic license, and ArcPy.
Your question is a "duplicate" of Sorting grid cells in fishnet grid by location and number using QGIS? but using arcpy:
import arcpy
fc = r'C:\data.gdb\features' #Change
field_to_update = 'somefield' #Change, needs to be added before running the code
decimals = 0 #Rounding. You might need to adjust to get desired output. My coordinates are in meters so I use zero decimals. If your grid is tilted, try a negative value, -1 will give 123.452->120
grids = [i for i in arcpy.da.SearchCursor(fc,['SHAPE@X','SHAPE@Y','OID@'])] #List all grids with coords and objectid
grids.sort(key=lambda k: (round(k[1],decimals),round(-k[0],decimals)), reverse=True) #Sort by coords
order = [i[2] for i in grids] #Fetch objectids from sorted grids
d = {k:v for (v,k) in list(enumerate(order))} #Add counting number to each objectid as a dictionary of id:counting number
#Update field
with arcpy.da.UpdateCursor(fc,['OID@',field_to_update]) as cursor:
for row in cursor:
row[1]=d[row[0]]+1
cursor.updateRow(row)
The approach I would suggest to achieve this result is to create points from polygons which then allows for those nodes to be labelled base on the attribute style of your choice.
Esri's [Feature To Point](http://pro.arcgis.com/en/pro-app/tool-reference/data-management/feature-to-point.htm
Here is a sample code from that link:
import arcpy
from arcpy import env
env.workspace = "C:/data"
arcpy.FeatureToPoint_management("parcels.shp", "c:/data/output/parcels_center.shp",
"CENTROID")