<?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 Select by Location Error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/select-by-location-error/m-p/521924#M40906</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a script that should select points by location, and then switch the selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have made the input feature classes in-memory layers using the MakeFeatureLayer tool, and the print out says these have been made successfully, however, when the script runs the SelectLayerByLocation script I get the following error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ExecuteError: Failed to execute. Parameters are not valid.&lt;/P&gt;&lt;P&gt;ERROR 000368: Invalid input data.&lt;/P&gt;&lt;P&gt;ERROR 000732: Selecting Features: Dataset S:/Rachel/Data/UTA_Data.gdb/newStopsFL does not exist or is not supported&lt;/P&gt;&lt;P&gt;Failed to execute (SelectLayerByLocation).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried this using feature classes and shapefiles and converting those to in memory layers and both have failed. Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os

#workspace &amp;amp; parameters
workspace = arcpy.env.workspace&amp;nbsp; = "S:/Rachel/Data/UTA_Data.gdb"
if not os.path.exists(workspace): os.makedirs(workspace)
arcpy.env.overwriteOutput = True

#Input Data
newStops = "S:/Rachel/Data/UTA_Data.gdb/newStopstest" #change to user input
clipBoundary = "S:/Rachel/Data/UTA_Data/Clip_Boundary.shp"


#Clip new stops dataset to campus boundary
clippedStops = workspace+"/clippedStops"
arcpy.Clip_analysis(newStops, clipBoundary, clippedStops)
print arcpy.GetMessages()+"\n"

#Count record #'s in both new and old sets
oldStopsCount = arcpy.GetCount_management(oldStops)
oldCntResults = int(oldStopsCount.getOutput(0))
print "There are "+str(oldCntResults)+" old stops.\n"
newStopsCount = arcpy.GetCount_management(clippedStops)
newCntResults = int(newStopsCount.getOutput(0))
print "There are "+str(newCntResults)+" new stops.\n"

if newCntResults &amp;lt; oldCntResults: 
#then stops from the old feature class need to be selected out and deleted

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Convert new &amp;amp; old stops to a feature layer
&amp;nbsp;&amp;nbsp;&amp;nbsp; newStopsFL = workspace+"/newStopsFL"
&amp;nbsp;&amp;nbsp;&amp;nbsp; oldStopsFL = workspace+"/oldStopsFL"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(clippedStops, newStopsFL)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()+"\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(oldStops, oldStopsFL)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()+"\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Select by Location
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(oldStopsFL,"INTERSECT",newStopsFL,0,"SWITCH_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()
&amp;nbsp;&amp;nbsp;&amp;nbsp; oldStopsCount2 = arcpy.GetCount_management(oldStopsFL)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print oldStopsCount2

else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "done"&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 22:45:53 GMT</pubDate>
    <dc:creator>RachelAlbritton</dc:creator>
    <dc:date>2021-12-11T22:45:53Z</dc:date>
    <item>
      <title>Select by Location Error</title>
      <link>https://community.esri.com/t5/python-questions/select-by-location-error/m-p/521924#M40906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a script that should select points by location, and then switch the selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have made the input feature classes in-memory layers using the MakeFeatureLayer tool, and the print out says these have been made successfully, however, when the script runs the SelectLayerByLocation script I get the following error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ExecuteError: Failed to execute. Parameters are not valid.&lt;/P&gt;&lt;P&gt;ERROR 000368: Invalid input data.&lt;/P&gt;&lt;P&gt;ERROR 000732: Selecting Features: Dataset S:/Rachel/Data/UTA_Data.gdb/newStopsFL does not exist or is not supported&lt;/P&gt;&lt;P&gt;Failed to execute (SelectLayerByLocation).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried this using feature classes and shapefiles and converting those to in memory layers and both have failed. Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os

#workspace &amp;amp; parameters
workspace = arcpy.env.workspace&amp;nbsp; = "S:/Rachel/Data/UTA_Data.gdb"
if not os.path.exists(workspace): os.makedirs(workspace)
arcpy.env.overwriteOutput = True

#Input Data
newStops = "S:/Rachel/Data/UTA_Data.gdb/newStopstest" #change to user input
clipBoundary = "S:/Rachel/Data/UTA_Data/Clip_Boundary.shp"


#Clip new stops dataset to campus boundary
clippedStops = workspace+"/clippedStops"
arcpy.Clip_analysis(newStops, clipBoundary, clippedStops)
print arcpy.GetMessages()+"\n"

#Count record #'s in both new and old sets
oldStopsCount = arcpy.GetCount_management(oldStops)
oldCntResults = int(oldStopsCount.getOutput(0))
print "There are "+str(oldCntResults)+" old stops.\n"
newStopsCount = arcpy.GetCount_management(clippedStops)
newCntResults = int(newStopsCount.getOutput(0))
print "There are "+str(newCntResults)+" new stops.\n"

if newCntResults &amp;lt; oldCntResults: 
#then stops from the old feature class need to be selected out and deleted

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Convert new &amp;amp; old stops to a feature layer
&amp;nbsp;&amp;nbsp;&amp;nbsp; newStopsFL = workspace+"/newStopsFL"
&amp;nbsp;&amp;nbsp;&amp;nbsp; oldStopsFL = workspace+"/oldStopsFL"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(clippedStops, newStopsFL)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()+"\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(oldStops, oldStopsFL)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()+"\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Select by Location
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(oldStopsFL,"INTERSECT",newStopsFL,0,"SWITCH_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()
&amp;nbsp;&amp;nbsp;&amp;nbsp; oldStopsCount2 = arcpy.GetCount_management(oldStopsFL)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print oldStopsCount2

else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "done"&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:45:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-location-error/m-p/521924#M40906</guid>
      <dc:creator>RachelAlbritton</dc:creator>
      <dc:date>2021-12-11T22:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Select by Location Error</title>
      <link>https://community.esri.com/t5/python-questions/select-by-location-error/m-p/521925#M40907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So those are the name of the layers.&amp;nbsp; Layer names should not include a workspace path, just a layer name.&amp;nbsp;&amp;nbsp; Change the code to:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# You need to create a variable named oldStops in your code:
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oldStops = workspace+&lt;SPAN class="string" style="font-weight: inherit; font-style: inherit; color: blue; font-size: 9pt !important; background-color: inherit;"&gt;"oldStops"&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newStopsFL = "&lt;SPAN class="string" style="font-weight: inherit; font-style: inherit; color: blue; font-size: 9pt !important; background-color: inherit;"&gt;newStopsFL"&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; oldStopsFL = "&lt;SPAN class="string" style="font-weight: inherit; font-style: inherit; color: blue; font-size: 9pt !important; background-color: inherit;"&gt;oldStopsFL"&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(clippedStops, newStopsFL)&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important; background-color: inherit;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt; arcpy.GetMessages()+&lt;/SPAN&gt;&lt;SPAN class="string" style="font-weight: inherit; font-style: inherit; color: blue; font-size: 9pt !important; background-color: inherit;"&gt;"\n"&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(oldStops, oldStopsFL)&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important; background-color: inherit;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt; arcpy.GetMessages()+&lt;/SPAN&gt;&lt;SPAN class="string" style="font-weight: inherit; font-style: inherit; color: blue; font-size: 9pt !important; background-color: inherit;"&gt;"\n"&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: inherit; color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;The variable oldStops is nothing, since you never initialized a path to a feature class for that variable in your code, so it won't exist.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:45:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-location-error/m-p/521925#M40907</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-11T22:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: Select by Location Error</title>
      <link>https://community.esri.com/t5/python-questions/select-by-location-error/m-p/521926#M40908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Richard - that was it&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2016 20:13:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-location-error/m-p/521926#M40908</guid>
      <dc:creator>RachelAlbritton</dc:creator>
      <dc:date>2016-06-20T20:13:46Z</dc:date>
    </item>
  </channel>
</rss>

