How can I assign grid values to the squares of a fishnet grid?

9841
15
Jump to solution
06-09-2015 06:02 AM
RyanGardner-Cook
New Contributor III

Hello,

I am working with a fishnet grid that I created but cannot figure out how to populate the attribute table of the shapefile with the corresponding grid designation. 

The details of the grid are as follows:
The X of the grid originally started with A and ended with AX. We have since had to broaden it both east and west to include YE through ZZ, then A through CT (so 146 columns in the grid). The Y of the grid is 1 through 147.  Each grid square is 5x5 meters.

There must be something I am missing in order to assign grid values to each square.  I have played around a bit with attribute assist, and editing a grid template for Make Grids and Graticules Layer (both of which are new to me).  I have also started playing around with creating rows and columns of polygons named according to the grid and named accordingly and spatially joining them with the grid squares...  I haven't quite been able to figure it out with any of these, and I figure there must be a simpler way, right?

Cheers,

Ryan

Tags (3)
15 Replies
XanderBakker
Esri Esteemed Contributor

You should change the function that corrects the column number. So replace lines 49 - 56 by these lines:

def correctCol(col):
    # starting at AA
    return col + 26

This will yield a column number that will start at AA (=27).

The error that make your rows start at 0 (probably due to the extent defined) can be easiest (quick and dirty) corrected by simply adding 1 to the row number at line 25:

            rownum = getRowNumber(ext.YMin, ymax, height) + 1

The alternative would be to check the extent defined and adjust accordingly.

RyanGardner-Cook
New Contributor III

Fantastic, thank you Xander!  This has been immensely helpful.  We're out in the field for a limited amount of time and you have no idea how important these things were.

XanderBakker
Esri Esteemed Contributor

Glad it was helpful! You're welcome

0 Kudos
RyanGardner-Cook
New Contributor III

Thank you, this worked brilliantly!!! 

It's a shame that there isn't a tool for this.  I have wanted to get into python scripting a bit more as my team's GIS needs increase.  Do you have any recommendations for tutorials to get going with?

0 Kudos
RyanGardner-Cook
New Contributor III

Thank you very much for the list of resources!  The explanation of the code helps immensely as well.  I've played around with R a bit and they seem pretty similar.

0 Kudos