I'm working with west to east river features and I need to index a grid using only numbers and accordinly to columns and not lines. The grid index features tool gives me this numerical sequence of index, for a grid with 3 lines and 6 columns:




But I really need this one:




Any tips?


To do this I think you will need to look past the Grid Index Features and Create Fishnet tools and instead use ArcPy geometry with nested for loops to generate rectangular polygons in the order that you want.

I just adapted some code from my Challenging Times with Python and ArcPy for ArcGIS Pro eLearning course to do that here. I write my output to the default geodatabase in a project named TestProject in C:\Temp\Projects.

import arcpy

gridFC = r"C:\Temp\Projects\TestProject\TestProject.gdb\gridFC"

upperX = 0
upperY = 3
colWidth = 1
rowHeight = 1
numRows = 3
numColumns = 6
iCursor = arcpy.da.InsertCursor(gridFC, ["SHAPE@"])

for i in range(0, numColumns):
    for j in range(0, numRows):
        array = arcpy.Array(
            [arcpy.Point(upperX + i*colWidth,
                         upperY - j*rowHeight),
             arcpy.Point(upperX + i*colWidth + colWidth,
                         upperY - j*rowHeight),
             arcpy.Point(upperX + i*colWidth + colWidth,
                         upperY - j*rowHeight - rowHeight),
             arcpy.Point(upperX + i*colWidth,
                         upperY - j*rowHeight - rowHeight)])
        polygon = arcpy.Polygon(array)
del iCursor

This is the output feature class labeled using its OBJECTID:

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.