<?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 Re: Extract by Mask for each feature in a feature class in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/extract-by-mask-for-each-feature-in-a-feature/m-p/561025#M18552</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I am trying to create a python script to loop through each feature in a feature class and use each feature as the mask for an extract by mask. &lt;BR /&gt;&lt;BR /&gt;Basically I&lt;STRONG&gt; have 12 polygons and want to calculate the mean value of a raster for each polygon &lt;/STRONG&gt;- I could split the feature class into 12 feature classes each with one feature and loop through a list of the feature classes but that doesn't seem like the most elegant solution.&lt;BR /&gt;&lt;BR /&gt;Any suggestions?&lt;BR /&gt;&lt;BR /&gt;I tried a using a search cursor to loop through each row and use each row as the mask input value but get&amp;nbsp; an "Error in executing tool" error. &lt;BR /&gt;&lt;BR /&gt;How do I covert the row object into an input for the tool?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;Richard Nauman&lt;BR /&gt;Spatial Analysis Program Manager&lt;BR /&gt;National Center for Conservation Science and Policy&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Richard, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want to calculate statistics of a raster you could use the Zonal Statistics tool in Spatial Analyst. It should give you what you want without needing to code. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Nooski&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 21 Jun 2010 05:52:40 GMT</pubDate>
    <dc:creator>StefanHaglund1</dc:creator>
    <dc:date>2010-06-21T05:52:40Z</dc:date>
    <item>
      <title>Extract by Mask for each feature in a feature class</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/extract-by-mask-for-each-feature-in-a-feature/m-p/561022#M18549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to create a python script to loop through each feature in a feature class and use each feature as the mask for an extract by mask. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Basically I have 12 polygons and want to calculate the mean value of a raster for each polygon - I could split the feature class into 12 feature classes each with one feature and loop through a list of the feature classes but that doesn't seem like the most elegant solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried a using a search cursor to loop through each row and use each row as the mask input value but get&amp;nbsp; an "Error in executing tool" error. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How do I covert the row object into an input for the tool?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Richard Nauman&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Spatial Analysis Program Manager&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;National Center for Conservation Science and Policy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jun 2010 23:10:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/extract-by-mask-for-each-feature-in-a-feature/m-p/561022#M18549</guid>
      <dc:creator>RichNauman</dc:creator>
      <dc:date>2010-06-18T23:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Extract by Mask for each feature in a feature class</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/extract-by-mask-for-each-feature-in-a-feature/m-p/561023#M18550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Create an array object to receive the geometry from the row.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Then you can use that temporary feature as a mask polygon.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Jun 2010 10:48:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/extract-by-mask-for-each-feature-in-a-feature/m-p/561023#M18550</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2010-06-19T10:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: Extract by Mask for each feature in a feature class</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/extract-by-mask-for-each-feature-in-a-feature/m-p/561024#M18551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You need a search cursor and as you loop through the feature class table create a feature layer with each feature, then use the feature layer to clip your raster.&amp;nbsp; Here is a little bit of code that should help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wrows = gp.SearchCursor(WatershedPath)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wrow = Wrows.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Nfeatures = gp.GetCount_management(WatershedPath)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.addmessage(str(Nfeatures) + " Records to Process")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;count = 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;while Wrow:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WFValue = str(Wrow.GetValue(WLayerF))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.addmessage("Processing watershed " + str(WFValue))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.MakeFeatureLayer_management(WatershedPath, "lyr", "OBJECTID="+str(Wrow.OBJECTID))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.ExtractbyMask_sa(IFI, "lyr", OutFolder + "/" + WFValue)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.delete("lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Wrow = Wrows.next()[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Watch for the indent as I just can't figure out how to post python code like in the old forum.&amp;nbsp; How the hell does one post code in this contraption?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Jun 2010 18:22:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/extract-by-mask-for-each-feature-in-a-feature/m-p/561024#M18551</guid>
      <dc:creator>JeffLee</dc:creator>
      <dc:date>2010-06-20T18:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: Extract by Mask for each feature in a feature class</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/extract-by-mask-for-each-feature-in-a-feature/m-p/561025#M18552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I am trying to create a python script to loop through each feature in a feature class and use each feature as the mask for an extract by mask. &lt;BR /&gt;&lt;BR /&gt;Basically I&lt;STRONG&gt; have 12 polygons and want to calculate the mean value of a raster for each polygon &lt;/STRONG&gt;- I could split the feature class into 12 feature classes each with one feature and loop through a list of the feature classes but that doesn't seem like the most elegant solution.&lt;BR /&gt;&lt;BR /&gt;Any suggestions?&lt;BR /&gt;&lt;BR /&gt;I tried a using a search cursor to loop through each row and use each row as the mask input value but get&amp;nbsp; an "Error in executing tool" error. &lt;BR /&gt;&lt;BR /&gt;How do I covert the row object into an input for the tool?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;Richard Nauman&lt;BR /&gt;Spatial Analysis Program Manager&lt;BR /&gt;National Center for Conservation Science and Policy&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Richard, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want to calculate statistics of a raster you could use the Zonal Statistics tool in Spatial Analyst. It should give you what you want without needing to code. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Nooski&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jun 2010 05:52:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/extract-by-mask-for-each-feature-in-a-feature/m-p/561025#M18552</guid>
      <dc:creator>StefanHaglund1</dc:creator>
      <dc:date>2010-06-21T05:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extract by Mask for each feature in a feature class</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/extract-by-mask-for-each-feature-in-a-feature/m-p/561026#M18553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the replies everyone.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Snoop pointed me in the direction I needed to go - The MakeFeatureLayer_management step with the where clause is what I didn't know how to do. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Richard Nauman&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Spatial Analysis Program Manager&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;National Center for Conservation Science and Policy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jun 2010 22:28:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/extract-by-mask-for-each-feature-in-a-feature/m-p/561026#M18553</guid>
      <dc:creator>RichNauman</dc:creator>
      <dc:date>2010-06-22T22:28:05Z</dc:date>
    </item>
  </channel>
</rss>

