<?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: Arcpy Select By Attribute in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-select-by-attribute/m-p/1501450#M70986</link>
    <description>&lt;P&gt;I've noticed some odd behavior from GridIndex features lately. Have you verified that the selection isn't occuring?&lt;/P&gt;&lt;P&gt;To test it, you can run a CopyFeatures on the selected layer and see if it's actually working. If that's working, try saving that copied layer to a 'memory/temp_selected' layer and indexing that.&lt;/P&gt;&lt;P&gt;If your total feature count isn't that high, you can also create a feature buffer that's dissolved into a single shape then pass that shape to an UpdateCursor spatial filter on the index of the whole grid feature set, then just re-number the grid features line by line (the insertion order matches the number order so re-numbering is trivial with an enumerate() or an index variable)&lt;/P&gt;&lt;P&gt;I'm currently on mobile, but if you need more help I can draft up some code for you.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jul 2024 05:43:39 GMT</pubDate>
    <dc:creator>HaydenWelch</dc:creator>
    <dc:date>2024-07-04T05:43:39Z</dc:date>
    <item>
      <title>Arcpy Select By Attribute</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-select-by-attribute/m-p/1500617#M70972</link>
      <description>&lt;P&gt;I have some code I wrote out that creates a grid index from a selection in a layer. However, I just recently upgraded from Pro 3.2 to Pro 3.3 and now the select by attribute doesn't seem to work in the code at all. Here is the original code with layer being a layer in the map and field and attribute as text values.&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.management.SelectLayerByAttribute(&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; in_layer_or_view=layer,&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; selection_type="NEW_SELECTION",&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; where_clause="{0} = '{1}'".format(field, attribute),&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; invert_where_clause=None&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I haven't changed the code and looking at the documentation on it, the code should work, but it isn't. Any suggestions would be great!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I did also try this:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;filter = "{0} = '{1}'".format(field, attribute)&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.management.SelectLayerByAttribute(layer,"NEW_SELECTION",filter)&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;And unfortunately that didn't work either. &lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 02 Jul 2024 20:47:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-select-by-attribute/m-p/1500617#M70972</guid>
      <dc:creator>jbrower</dc:creator>
      <dc:date>2024-07-02T20:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy Select By Attribute</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-select-by-attribute/m-p/1501450#M70986</link>
      <description>&lt;P&gt;I've noticed some odd behavior from GridIndex features lately. Have you verified that the selection isn't occuring?&lt;/P&gt;&lt;P&gt;To test it, you can run a CopyFeatures on the selected layer and see if it's actually working. If that's working, try saving that copied layer to a 'memory/temp_selected' layer and indexing that.&lt;/P&gt;&lt;P&gt;If your total feature count isn't that high, you can also create a feature buffer that's dissolved into a single shape then pass that shape to an UpdateCursor spatial filter on the index of the whole grid feature set, then just re-number the grid features line by line (the insertion order matches the number order so re-numbering is trivial with an enumerate() or an index variable)&lt;/P&gt;&lt;P&gt;I'm currently on mobile, but if you need more help I can draft up some code for you.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jul 2024 05:43:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-select-by-attribute/m-p/1501450#M70986</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2024-07-04T05:43:39Z</dc:date>
    </item>
  </channel>
</rss>

