<?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: Help with using definition query in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/help-with-using-definition-query/m-p/653562#M50911</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your reply - model builder is a good idea but it is part of a bigger script, so would prefer to have it in Python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've managed to sort it now and the definitionquery works!!:D&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Feb 2012 10:54:22 GMT</pubDate>
    <dc:creator>ClaireParsons1</dc:creator>
    <dc:date>2012-02-21T10:54:22Z</dc:date>
    <item>
      <title>Help with using definition query</title>
      <link>https://community.esri.com/t5/python-questions/help-with-using-definition-query/m-p/653560#M50909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd like some help using definition query with layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Basically, I want to clip a raster several times by using polygons within a feature class. My idea was to use Searchcursor to loop through each row - set the definitionquery for the featureclass, clip the raster, delete the definitionquery then repeat.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Would this work?&amp;nbsp; Has anyone got any other ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Claire&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 07:26:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-with-using-definition-query/m-p/653560#M50909</guid>
      <dc:creator>ClaireParsons1</dc:creator>
      <dc:date>2012-02-21T07:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help with using definition query</title>
      <link>https://community.esri.com/t5/python-questions/help-with-using-definition-query/m-p/653561#M50910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Claire,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Instead of writing a Python script, why not use model builder? You could have a &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00400000001n000000.htm"&gt;feature iterator &lt;/A&gt;&lt;SPAN&gt;that spews out a polygon one for each row (or even grouped by a case field) and this simply feeds into a clip raster tool as the clipping polygon?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 08:40:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-with-using-definition-query/m-p/653561#M50910</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2012-02-21T08:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Help with using definition query</title>
      <link>https://community.esri.com/t5/python-questions/help-with-using-definition-query/m-p/653562#M50911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your reply - model builder is a good idea but it is part of a bigger script, so would prefer to have it in Python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've managed to sort it now and the definitionquery works!!:D&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 10:54:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-with-using-definition-query/m-p/653562#M50911</guid>
      <dc:creator>ClaireParsons1</dc:creator>
      <dc:date>2012-02-21T10:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help with using definition query</title>
      <link>https://community.esri.com/t5/python-questions/help-with-using-definition-query/m-p/653563#M50912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you tried the layer object via arcpy.mapping?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Layer/00s300000008000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Layer/00s300000008000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once you reference a layer in a map document you can modify its query definition, for example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mxd = arcpy.mapping.MapDocument(r"path/to/map.mxd")
lyr = arcpy.mapping.ListLayers(mxd, "some layer name")[0]
lyr.definitionQuery = "[query] = 'here'"

#Do you raster clip here
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not clear on your requirements but you may not even need to use a SearchCursor.&amp;nbsp; Simply change the def query in some sort of loop.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:41:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-with-using-definition-query/m-p/653563#M50912</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2021-12-12T03:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Help with using definition query</title>
      <link>https://community.esri.com/t5/python-questions/help-with-using-definition-query/m-p/653564#M50913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I didn't test this code, but it should work something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;searchRows = arcpy.SearchCursor(myFC)
for searchRow in searchRow:
&amp;nbsp;&amp;nbsp;&amp;nbsp; myIdValue = searchRow.MY_FIELD_NAME
&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = r"C:\temp\test_" + str(myIdValue)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(myFC, "fl", "MY_FIELD_NAME = " + str(myIdValue))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Clip_management(inputRaster, "", outRaster, "fl", "", "ClippingGeometry")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:41:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-with-using-definition-query/m-p/653564#M50913</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-12T03:41:40Z</dc:date>
    </item>
  </channel>
</rss>

