I'm trying to iterate through several columns in a polygon file and generate a raster for each column with the Polygon2Raster. Unfortunately, I'm new to Python and I'm not able to generate a new raster for each column. There is a similar question here: Iterate Through Fields in Model Builder However that solution does not work entirely. My code is below. Currently that produces only one raster.
Thank you very much in advance for you help!
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r'D:\_Work\Output_vs1'
prov = 'prov_outln.shp'
outras = 'rastrat'
field_names = [f.name for f in arcpy.ListFields(prov)]
count = 2
while count < len(field_names):
count += 1
Thank you Dan for your reply!
The data type is Shapefile Feature Class. I want to iterate through each column of the attribute table of the polygon. The attribute table has 10 columns and the end result should be 10 raster files.
Oh I see, you want to use the columns as the attribute, The problem appears that 'outras' will get overwritten each time through the loop. You should be providing a full filename to the output (ie outras2, outras3 ...) with a file extension (ie tif). And are you really wanting a 5800 meter/foot cell size?
the simplest way would be to modify the script in the help topic and add a line with how you want to label your filenames, assuming you are familiar with python