4

I have used the Grid index feature tool to create an index grid. The label/attribution of the page names are populated in a "row" orientated manner. eg lef to right a1,a2,a3,a4,a5,a6 b1,b2,b3,b4,b5,b6 c1,c2,c3,c4,c5,c6enter image description here

How can I calculate a field so I can have the page names label/attribution in a "column" orientation?eg: a1,b1,c1,d1,e1 a2,b2,c2,d2,e2 a3,b3,c3,d3,e3 a4,b4,c4,d4,e4

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Haydlew
  • 417
  • 1
  • 4
  • 13

2 Answers2

3

Below is some code extracted from one of my training courses that should be adaptable to your situation:

# Add field to Map Grid to hold grid references created by concatenating 
# outputs from looping values 1 to 8 from North to South and A to H from
# West to East e.g. 1A to 8H for each of 64 maps
arcpy.AddField_management("MapGrid.shp","REF","TEXT","","","5")
rowCount = 0
with arcpy.da.UpdateCursor("MapGrid.shp",["FID","REF"]) as cursor:
    for row in cursor:
        leftPart = (rowCount % 8) + 1
        rightPart = ["A","B","C","D","E","F","G","H"][row[0] % 8]
        row[1] = str(leftPart)+str(rightPart)
        cursor.updateRow(row)


        if ((row[0]) % 64) == 63:
            rowCount = rowCount + 1

It produces grid references like those in the picture below:

enter image description here

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
  • Thanks for the quick response. Thats pretty much what Im after. Only issue I have is that im using arcmap 10.0....update row does not support indexing. :( Time to upgrade i think! – Haydlew Jul 20 '15 at 06:23
  • 1
    Upgrading to 10.1 (preferably all the way to 10.3.1) sounds like a good idea. That 10.0 to 10.1 upgrade was huge for ArcPy because it gives you arcpy.da, Python Add-Ins and Python Toolboxes. – PolyGeo Jul 20 '15 at 06:29
2

Try this field calculator (Python) on a new text field:

def CN(nCols,nRows,j):
 nR=divmod(j,nCols)[0]
 nC=divmod(j-nR*nCols,nRows)[1]
 theDiv = divmod(nC,26); SecondL = theDiv[1]
 FirstL = theDiv[0]; aLetter = chr(65 + FirstL) + chr(65 + SecondL)
 aLabel = aLetter + str(nR).zfill(2)
 return aLabel

CN(42,47, !PageNumber! )

If you want to see this:

enter image description here

FelixIP
  • 22,922
  • 3
  • 29
  • 61
  • thanks felix, I still get the row orientated attribution. At my end it doesn't replicate what i expected to see in your diagram. Im just trying to figure out why right now. – Haydlew Jul 21 '15 at 01:02
  • Are "OLD" the same as at my picture? – FelixIP Jul 21 '15 at 01:22
  • yes it the same if I label using the "pageName" field. – Haydlew Jul 21 '15 at 02:04
  • I got it working, I reran a new grid index then ran the calc over it again. My original must have inherited something unseen. Thanks this works great! Even with 10.0 – Haydlew Jul 21 '15 at 02:40
  • Good to know. +1 for not giving up – FelixIP Jul 21 '15 at 02:50
  • strange though. I have reattempted the process again and its once again orientating by row. I can figure out why it works on some grid index feature and not others. It returned column oriented values on an obscure shape...but returned out of sync for a more regular shape: eg rectangle. eg: aa01 | ab01 | ac01 | ad01 (/n)

    ac02 | ae02| ad02 | af02 (/n)

    ad03 | ae03 | af03 | ag03 (/n)

    – Haydlew Jul 21 '15 at 03:13
  • It should only work on rectangular output, i.e. no missing mesh. Also page numbering starts from 0 – FelixIP Jul 21 '15 at 03:46