I've got the following script to loop through a polygon dataset, but I keep getting a strange error that I can't fathom.
ERROR 000728: Field 10 does not exist within table
Failed to execute (PolygonToRaster).
I don't have a "Field 10" so im not sure why the PolyToRas tool is trying to access it.
Here's the script
# for loop to loop through each "group_extent" polygon in turn and create shadow polygons
with arcpy.da.SearchCursor(group_extent,['SHAPE@', 'GroupRef', 'Species', 'MaxHeight']) as cursor:
groupCount = 0
for fc in cursor:
# variables
shadowRas = "shadowRas"
shadowPnts = "memory\shadowPnts"
shadowPntsJoined = "memory\shadowPntsJoined"
cellsize = fc[3]
# polygon to raster
arcpy.conversion.PolygonToRaster(fc[0], cellsize, shadowRas, "CELL_CENTER", "NONE", cellsize, "DO_NOT_BUILD")
# raster to point
arcpy.conversion.RasterToPoint(shadowRas, shadowPnts, "Value")
arcpy.management.DeleteFeatures(shadowRas)
# join group data back to shadowPnts
arcpy.analysis.SpatialJoin(shadowPnts, group_extent, shadowPntsJoined)
Any ideas what's going on?
Solved! Go to Solution.
@JohannesLindner @Luke_Pinner thank you both. Excellent suggestions. Have implemented Johannes solution with success 👍