<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Iterate through columns in polygon in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/iterate-through-columns-in-polygon/m-p/282896#M9720</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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: &lt;A href="https://community.esri.com/thread/56324" target="_blank"&gt;Iterate Through Fields in Model Builder&lt;/A&gt; However that solution does not work entirely. My code is below. Currently that produces only one raster.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much in advance for you help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;arcpy

arcpy.env.overwriteOutput = &lt;SPAN style="color: #000080;"&gt;True
&lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;
&lt;/SPAN&gt;arcpy.env.workspace = &lt;SPAN style="color: #008000; font-weight: bold;"&gt;r'D:\_Work\Output_vs1'
&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-weight: bold;"&gt;
&lt;/SPAN&gt;prov = &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'prov_outln.shp'
&lt;/SPAN&gt;outras = &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'rastrat'
&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-weight: bold;"&gt;
&lt;/SPAN&gt;field_names = [f.name &lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;f &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;arcpy.ListFields(prov)]

count = &lt;SPAN style="color: #0000ff;"&gt;2 
&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;while &lt;/SPAN&gt;count &amp;lt; &lt;SPAN style="color: #000080;"&gt;len&lt;/SPAN&gt;(field_names):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.PolygonToRaster_conversion(prov,field_names[count],outras,&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"MAXIMUM_AREA"&lt;/SPAN&gt;,&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"NONE"&lt;/SPAN&gt;,&lt;SPAN style="color: #0000ff;"&gt;5800&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;count += 1&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 13:41:46 GMT</pubDate>
    <dc:creator>EginaMalaj</dc:creator>
    <dc:date>2021-12-11T13:41:46Z</dc:date>
    <item>
      <title>Iterate through columns in polygon</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/iterate-through-columns-in-polygon/m-p/282896#M9720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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: &lt;A href="https://community.esri.com/thread/56324" target="_blank"&gt;Iterate Through Fields in Model Builder&lt;/A&gt; However that solution does not work entirely. My code is below. Currently that produces only one raster.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much in advance for you help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;arcpy

arcpy.env.overwriteOutput = &lt;SPAN style="color: #000080;"&gt;True
&lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;
&lt;/SPAN&gt;arcpy.env.workspace = &lt;SPAN style="color: #008000; font-weight: bold;"&gt;r'D:\_Work\Output_vs1'
&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-weight: bold;"&gt;
&lt;/SPAN&gt;prov = &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'prov_outln.shp'
&lt;/SPAN&gt;outras = &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'rastrat'
&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-weight: bold;"&gt;
&lt;/SPAN&gt;field_names = [f.name &lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;f &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;arcpy.ListFields(prov)]

count = &lt;SPAN style="color: #0000ff;"&gt;2 
&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;while &lt;/SPAN&gt;count &amp;lt; &lt;SPAN style="color: #000080;"&gt;len&lt;/SPAN&gt;(field_names):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.PolygonToRaster_conversion(prov,field_names[count],outras,&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"MAXIMUM_AREA"&lt;/SPAN&gt;,&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"NONE"&lt;/SPAN&gt;,&lt;SPAN style="color: #0000ff;"&gt;5800&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;count += 1&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:41:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/iterate-through-columns-in-polygon/m-p/282896#M9720</guid>
      <dc:creator>EginaMalaj</dc:creator>
      <dc:date>2021-12-11T13:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate through columns in polygon</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/iterate-through-columns-in-polygon/m-p/282897#M9721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what is the form of your data?&amp;nbsp; &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/conversion-toolbox/polygon-to-raster.htm"&gt;&lt;STRONG&gt;PolygontoRaster&lt;/STRONG&gt;&lt;/A&gt; uses a polygon featureclass, shapefile or coverage, which only has one geometry field&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Dec 2017 22:58:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/iterate-through-columns-in-polygon/m-p/282897#M9721</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-12-19T22:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate through columns in polygon</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/iterate-through-columns-in-polygon/m-p/282898#M9722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Dan for your reply!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Dec 2017 23:07:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/iterate-through-columns-in-polygon/m-p/282898#M9722</guid>
      <dc:creator>EginaMalaj</dc:creator>
      <dc:date>2017-12-19T23:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate through columns in polygon</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/iterate-through-columns-in-polygon/m-p/282899#M9723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh I see, you want to use the columns as the attribute,&amp;nbsp; The problem appears that 'outras' will get overwritten each time through the loop.&amp;nbsp; You should be providing a full filename to the output&amp;nbsp; (ie outras2, outras3 ...) with a file extension (ie tif).&amp;nbsp; And are you really wanting a 5800 meter/foot cell size?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Dec 2017 23:30:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/iterate-through-columns-in-polygon/m-p/282899#M9723</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-12-19T23:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate through columns in polygon</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/iterate-through-columns-in-polygon/m-p/282900#M9724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you are correct. Any idea how I can automatically generate those rasters?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cell size is ok. Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Dec 2017 23:37:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/iterate-through-columns-in-polygon/m-p/282900#M9724</guid>
      <dc:creator>EginaMalaj</dc:creator>
      <dc:date>2017-12-19T23:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate through columns in polygon</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/iterate-through-columns-in-polygon/m-p/282901#M9725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Dec 2017 00:23:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/iterate-through-columns-in-polygon/m-p/282901#M9725</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-12-20T00:23:15Z</dc:date>
    </item>
  </channel>
</rss>

