<?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 query data and switch selection in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-query-data-and-switch-selection/m-p/1033128#M60214</link>
    <description>&lt;P&gt;I dont think the query in makefeaturesmanagement is making a layer where those features matching the query are selected, rather it is creating a layer which is a subset which matches the query.&lt;/P&gt;&lt;P&gt;The switch selection is therefore taking none selected to all selected.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Mar 2021 21:23:13 GMT</pubDate>
    <dc:creator>DavidPike</dc:creator>
    <dc:date>2021-03-04T21:23:13Z</dc:date>
    <item>
      <title>Arcpy query data and switch selection</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-query-data-and-switch-selection/m-p/1033081#M60210</link>
      <description>&lt;P&gt;Hello everyone&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Its looks like these two cases&amp;nbsp; produce the same results:&lt;/P&gt;&lt;P&gt;querySAOall = populated with a condition&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="hljs-comment"&gt;# Make feature layer from my input data&lt;/SPAN&gt;
arcpy.MakeFeatureLayer_management(inSAO, &lt;SPAN class="hljs-string"&gt;"LayerAll"&lt;/SPAN&gt;)

&lt;SPAN class="hljs-comment"&gt;# Select by attribute and switch the selection&lt;/SPAN&gt;
arcpy.SelectLayerByAttribute_management (&lt;SPAN class="hljs-string"&gt;"LayerAll"&lt;/SPAN&gt;, &lt;SPAN class="hljs-string"&gt;"NEW_SELECTION"&lt;/SPAN&gt;, querySAOall)
arcpy.SelectLayerByAttribute_management (&lt;SPAN class="hljs-string"&gt;"LayerAll"&lt;/SPAN&gt;, &lt;SPAN class="hljs-string"&gt;"SWITCH_SELECTION"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;or:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="hljs-comment"&gt;# Make feature layer from my input data&lt;/SPAN&gt;
arcpy.MakeFeatureLayer_management(inSAO, &lt;SPAN class="hljs-string"&gt;"LayerAll"&lt;/SPAN&gt;, querySAOall)

&lt;SPAN class="hljs-comment"&gt;# Select by attribute and switch the selection&lt;/SPAN&gt;
arcpy.SelectLayerByAttribute_management (&lt;SPAN class="hljs-string"&gt;"LayerAll"&lt;/SPAN&gt;, &lt;SPAN class="hljs-string"&gt;"SWITCH_SELECTION"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For me in the second case, the second&amp;nbsp; "arcpy.SelectLayerByAttribute_management" line should return 0 because it is trying to select&amp;nbsp; from a "&lt;SPAN&gt;SWITCH_SELECTION", and in the previous&amp;nbsp;arcpy.MakeFeatureLayer_managemen we only select records with the condition&amp;nbsp;querySAOall&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;arcpy.MakeFeatureLayer_management(inSAO", &lt;SPAN&gt;"LayerAll"&lt;/SPAN&gt;, querySAOall) arcpy.SelectLayerByAttribute_management (&lt;SPAN&gt;"LayerAll"&lt;/SPAN&gt;, &lt;SPAN&gt;"SWITCH_SELECTION"&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please advise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 20:38:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-query-data-and-switch-selection/m-p/1033081#M60210</guid>
      <dc:creator>JoseSanchez</dc:creator>
      <dc:date>2021-03-04T20:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy query data and switch selection</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-query-data-and-switch-selection/m-p/1033128#M60214</link>
      <description>&lt;P&gt;I dont think the query in makefeaturesmanagement is making a layer where those features matching the query are selected, rather it is creating a layer which is a subset which matches the query.&lt;/P&gt;&lt;P&gt;The switch selection is therefore taking none selected to all selected.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 21:23:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-query-data-and-switch-selection/m-p/1033128#M60214</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-03-04T21:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy query data and switch selection</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-query-data-and-switch-selection/m-p/1033210#M60220</link>
      <description>&lt;P&gt;David is correct, passing an SQL WHERE clause to MakeFeatureLayer creates a layer with a DefinitionQuery set to the SQL WHERE clause.&amp;nbsp; The definition query is separate from selections and applies before the Select By tools.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 22:58:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-query-data-and-switch-selection/m-p/1033210#M60220</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-03-04T22:58:22Z</dc:date>
    </item>
  </channel>
</rss>

