Sunday, 1 December 2019

Controlling label/attributes of grid/fishnet index using ArcGIS for Desktop and ArcPy?


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



Answer



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


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...