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
Solved! Go to Solution.
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.
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.
Glad it was helpful! You're welcome
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?
It is relatively easy to create a tool from it, but this would probably require some more intelligence on detecting the size of the fishnet grids and rows and columns (ArcGIS Help (10.2, 10.2.1, and 10.2.2))
Some resources for learning Python/arcpy...
python:
Coursera - Free Online Courses From Top Universities
Table of Contents — How to Think like a Computer Scientist: Interactive Edition
Python for Beginners - Python Training Course - Udemy
books:
Esri Press | GIS Books & Tutorials - Buy Books Online
arcpy:
Python for ArcGIS | ArcGIS Resource Center
some blogs in GeoNet:
...and of course:
ArcPy Café | Get all your ArcGIS Python Recipes here!
ArcGIS Help (10.2, 10.2.1, and 10.2.2)
ArcGIS Help (10.2, 10.2.1, and 10.2.2)
and
What is ArcPy?—Help | ArcGIS for Desktop
ArcGIS Pro ArcPy Reference—ArcGIS Pro | ArcGIS for Professionals
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.