1

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:

1;2;3;4;5;6;

7;8;9;10;11;12;

13;14;15;16;17;18

But I really need this one:

1;4;7;10;13;16

2;5;8;11;14;17

3;6;9;12;15;18

Any tips?

2

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

arcpy.management.CreateFeatureclass(
    r"C:\Temp\Projects\TestProject\TestProject.gdb","gridFC","POLYGON")
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)
        iCursor.insertRow([polygon])
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.