I have a fishnet grid (polygon SHP), and all the little fishnets have a "Zone_ID." There are generally several dozen to a few hundred fishnet polys associated with each Zone_ID. I'm trying to number each fishnet poly based on the zone. Screenshot below is a simple example of what I'm tring to code. (Fishnets have already been intersected with zones, and the topology is correct.)
arcpy.AddField_management("MyFishnet_wZones.shp", "Fishnet_ID", "SHORT", field_is_nullable = "NULLABLE") nPolygons = int(arcpy.GetCount_management("MyZones.shp").getOutput(0)) # length nPolygons is the total number of zones for n in range(0, nPolygons): counter = 1 with arcpy.da.UpdateCursor("MyFishnet_wZones.shp", ["Zone_ID", "Fishnet_ID"]) as cursor: for row in cursor: while row == n + 1: # because Zone_ID starts at 1, not 0 row = counter cursor.updateRow(row) counter += 1
And here's the error:
File "", line X, in <module> cursor.updateRow(row) RuntimeError: The row contains a bad value.