AnsweredAssumed Answered

Iterate through columns in polygon

Question asked by egina007 on Dec 19, 2017
Latest reply on Dec 19, 2017 by Dan_Patterson

Hello,

 

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!

 

import arcpy

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):
    arcpy.PolygonToRaster_conversion(prov,field_names[count],outras,"MAXIMUM_AREA","NONE",5800)
    count += 1

Outcomes