Seems now in v10.2 the 'grid_code' field (field automatically generated when converting raster layers to vector layers) is now named 'gridcode' (no underscore).
...not that this ^%$#s up all my scripts or anything... Oh wait, it does!
Yes, I know it's a pain but before the change shapefile output for these tools used the field name "gridcode" and gdb feature class output used "grid_code". In the long run I'm glad they changed it so these tools always generate a field with a consistent name, regardless of output feature class format.
I'm sure I have read in the T&C of the software that it states that subtle changes are made to any tool so as to make unnecessary work for you... It's the standard contractual agreement we all willingly entered into.
Good point Curtis - I wasn't aware of that.
As I recall, long ago it also used to be 'GRID_CODE' in caps... Maybe that flavor was for coverages.
OK - Thought I was imagining stuff for a while but:
In v10.2.2, the StreamToFeature tool still pumps out 'grid_code' field (or 'GRID_CODE' if using a shapefile. Thus. now with the advent of the 'gridcode' flavor in v10.2, the problem is actually worse now in that there are now three different flavors: 'gridcode', 'grid_code', and 'GRID_CODE' .... Right after I did a blanker find='grid_code' and replace='gridcode'.
*&(^(^^%!!!!! I can't win...
Note the StreamToFeature tool in v10.2 returns a schema of:
For shapefile format: 'ARCID', 'GRID_CODE', 'FROM_NODE', 'TO_NODE'
For FGDB format: 'arcid', 'grid_code', 'from_node', 'to_node'
Thank goodness field names are case insensitive everywhere but INFO (unless you set $CASE-FLAG haha)
Yet in Python:
>>> 'grid_code' == 'gridcode' == 'GRID_CODE'
False
So much pain in the world....
def GetGridCode(tbl): """Get grid code from table""" gc = arcpy.ListFields(tbl, "GRID_CODE") if not gc: gc = arcpy.ListFields(tbl, "GRIDCODE") else: raise Exception("No GRIDCODE field in " + tbl) return gc.upper()
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.