<?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: Selecting Features by Location in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578739#M45357</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Make a layer from the feature class
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.MakeFeatureLayer_management(gate, "gate_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.MakeFeatureLayer_management(tableName_e, "tableName_e_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.MakeFeatureLayer_management(tableName_vec, "tableName_vec_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Feature Layers created."

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Selecting the vectors that intersect the gate
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation_management(tableName_vec_lyr, "intersect", gate_lyr)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add to selection, points that intersect with the previously selected vectors
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation_management(tableName_e_lyr, "intersect", tableName_vec_lyr, "ADD_TO_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove initial vector selection
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation_management(tableName_vec_lyr, "intersect", gate_lyr, "REMOVE_FROM_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Write the selected features to a new feature class
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.CopyFeatures(tableName_e_lyr, tableName_sim)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;The feature layers are successfully created, and the first "select layer by location " works, but it doesn't seem to perform the 2 subsequent "select layer by location"'s.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You need to use the proper syntax.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SelectLayerByLocation_management (in_layer, overlap_type, select_features, search_distance, selection_type) &lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://webhelp.esri.com/arcgisdesktop/9.3/body.cfm?id=1877&amp;amp;pid=1865&amp;amp;topicname=Select%20Layer%20By%20Location%20%28Data%20Management%29&amp;amp;tocVisable=0" rel="nofollow noopener noreferrer" target="_blank"&gt;http://webhelp.esri.com/arcgisdesktop/9.3/body.cfm?id=1877&amp;amp;pid=1865&amp;amp;topicname=Select%20Layer%20By%20Location%20%28Data%20Management%29&amp;amp;tocVisable=0&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are trying to insert "ADD_TO_SELECITON" in the search distance parameter.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 00:52:17 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2021-12-12T00:52:17Z</dc:date>
    <item>
      <title>Selecting Features by Location</title>
      <link>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578734#M45352</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 select features by location from the "tableName_vctor" layer as defined (and highlighted in red), then export them to a new shapefile and am receiving the following errors (refer to the blue section):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000622: Failed to execute (Select Layer By Location). Parameters are not valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000628: Cannot set input into parameter search_distance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;any insight as to how to fix these errors is much appreciated&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thank-you in advance! &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Iterates through each of the input text files
&amp;nbsp;&amp;nbsp;&amp;nbsp; for v in list(table):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Removes the file extension
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tableName = os.path.splitext(v)[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Variables
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tableName_line = tableName + str("_line.shp")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tableName_vctor = tableName + str("_vctor.shp")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tableName_e = tableName + str ("_e.shp")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gate = r"C:\gis\gate.shp"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tableName_sim = tableName + str("_sim.shp")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Creating vectors from xy coordinates
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.Toolbox = r"C:\Program Files\ArcGIS\ArcToolbox\Toolboxes\Military Analyst Tools.tbx"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.TableToLine_ma(v, tableName_line, "Decimal Degrees", "sLat", "sLon", "eLat", "eLon", "False", "False")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.Project_management(tableName_line, tableName_vctor, "PROJCS['LCC']")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Selecting vectors that intersect a line, then points that intersect the vector, then removing the initial selection
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation(tableName_vctor, "intersect", gate, "NEW_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation(tableName_e, "intersect", tableName_vctor, "ADD_TO_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation(tableName_vctor, "intersect", gate, "REMOVE_FROM_SELECTION")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Write the selected features to a new feature class in the folder
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.CopyFeatures(tableName_sim, r"C:\gis\temp")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #If an error occurred while running the script, then print the messages
&amp;nbsp;&amp;nbsp;&amp;nbsp; print gp.GetMessages()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:38:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578734#M45352</guid>
      <dc:creator>LarissaPizzolato</dc:creator>
      <dc:date>2021-12-12T16:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Features by Location</title>
      <link>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578735#M45353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can only do selections on layers, not feature classes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, this is the syntax.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SelectLayerByLocation_management (in_layer, {overlap_type}, {select_features}, {search_distance}, {selection_type})&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jun 2012 18:54:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578735#M45353</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-06-11T18:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Features by Location</title>
      <link>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578736#M45354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;When creating the feature layer using the following code, &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

# Make a layer from the shapefiles
gp.MakeFeatureLayer("tableName_e.shp", "tableName_e_lyr")
gp.MakeFeatureLayer("tableName_vctor.shp", "tableName_vctor_lyr") &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to call on shapefiles that were made earlier in the code (the files in blue), yet I am getting this error: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute. Parameters are not valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000732: Input Features: Dataset tableName_e.shp does not exist or is not supported&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (MakeFeatureLayer).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:39:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578736#M45354</guid>
      <dc:creator>LarissaPizzolato</dc:creator>
      <dc:date>2021-12-12T16:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Features by Location</title>
      <link>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578737#M45355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The shapefile you specified is not found in geoprocessing workspace or &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;gp.workspace&lt;/SPAN&gt;&lt;SPAN&gt; was not declared.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So you have to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- declare &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;gp.workspace&lt;/SPAN&gt;&lt;SPAN&gt; which contains your shapefiles&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- provide full path (or variable with path) in &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;gp.MakeFeatureLayer_management()&lt;/SPAN&gt;&lt;SPAN&gt; tool&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2012 12:06:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578737#M45355</guid>
      <dc:creator>MarcinGasior</dc:creator>
      <dc:date>2012-06-12T12:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Features by Location</title>
      <link>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578738#M45356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Make a layer from the feature class
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.MakeFeatureLayer_management(gate, "gate_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.MakeFeatureLayer_management(tableName_e, "tableName_e_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.MakeFeatureLayer_management(tableName_vec, "tableName_vec_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Feature Layers created."

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Selecting the vectors that intersect the gate
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation_management(tableName_vec_lyr, "intersect", gate_lyr)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add to selection, points that intersect with the previously selected vectors
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation_management(tableName_e_lyr, "intersect", tableName_vec_lyr, "ADD_TO_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove initial vector selection
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation_management(tableName_vec_lyr, "intersect", gate_lyr, "REMOVE_FROM_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Write the selected features to a new feature class
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.CopyFeatures(tableName_e_lyr, tableName_sim)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The feature layers are successfully created, and the first "select layer by location " works, but it doesn't seem to perform the 2 subsequent "select layer by location"'s.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:52:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578738#M45356</guid>
      <dc:creator>LarissaPizzolato</dc:creator>
      <dc:date>2021-12-12T00:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Features by Location</title>
      <link>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578740#M45358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It says that the search distance is optional so I have tried to set it as "None", "Null", "No_Value", "", " ", "0", as I do not want to create a buffer, but rather only select the points that intersect with the specified vector... I can't seem to find any other alternative placeholder to setting it as blank.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You need to use the proper syntax.&lt;BR /&gt;SelectLayerByLocation_management (in_layer, overlap_type, select_features, search_distance, selection_type) &lt;BR /&gt;&lt;A href="http://webhelp.esri.com/arcgisdesktop/9.3/body.cfm?id=1877&amp;amp;pid=1865&amp;amp;topicname=Select%20Layer%20By%20Location%20%28Data%20Management%29&amp;amp;tocVisable=0"&gt;http://webhelp.esri.com/arcgisdesktop/9.3/body.cfm?id=1877&amp;amp;pid=1865&amp;amp;topicname=Select%20Layer%20By%20Location%20%28Data%20Management%29&amp;amp;tocVisable=0&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;You are trying to insert "ADD_TO_SELECITON" in the search distance parameter.&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2012 14:13:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578740#M45358</guid>
      <dc:creator>LarissaPizzolato</dc:creator>
      <dc:date>2012-06-12T14:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Features by Location</title>
      <link>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578741#M45359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Either of these should work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"" or "#"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
gp.SelectLayerByLocation_management(tableName_e_lyr, "intersect", tableName_vec_lyr, "", "ADD_TO_SELECTION")

gp.SelectLayerByLocation_management(tableName_vec_lyr, "intersect", gate_lyr, "#","REMOVE_FROM_SELECTION")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you getting an error or anything when these execute? Or just unexpected behaviour?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:52:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578741#M45359</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-12T00:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Features by Location</title>
      <link>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578742#M45360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;After you set an empty string (red) for the search_distance parameter:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;gp.SelectLayerByLocation_management(tableName_e_lyr, "intersect", tableName_vec_lyr, &lt;STRONG style="color: #ff0000;"&gt;""&lt;/STRONG&gt;, "ADD_TO_SELECTION")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please enclose the call with try-except block as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation_management(tableName_e_lyr, "intersect", tableName_vec_lyr, "", "ADD_TO_SELECTION")

except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print gp.GetMessages(2)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What error message do you get now?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:52:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578742#M45360</guid>
      <dc:creator>NobbirAhmed</dc:creator>
      <dc:date>2021-12-12T00:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Features by Location</title>
      <link>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578743#M45361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I added the try and except statement around the select layers by location by did not get any error messages generated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is what printed in the python shell: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Feature Layers created. (suggesting that the feature layers were created)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Selecting vectors that intersect the gate for:20041115011426_20041122011013 (this is the start of the select by location commands)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(i'm not sure why this is occuring after the feature layers should have aExecuting: MakeFeatureLayer E:\temp\5464648_vec.shp vec_lyr # # "CP CP VISIBLE NONE;startX startX VISIBLE NONE;startY startY VISIBLE NONE;dispX dispX VISIBLE NONE;dispY dispY VISIBLE NONE;sLat sLat VISIBLE NONE;sLon sLon VISIBLE NONE;theta theta VISIBLE NONE;pCorr pCorr VISIBLE NONE;pkStr pkStr VISIBLE NONE;cCorr cCorr VISIBLE NONE;conf conf VISIBLE NONE;velX velX VISIBLE NONE;velY velY VISIBLE NONE;endX endX VISIBLE NONE;endY endY VISIBLE NONE;eLat eLat VISIBLE NONE;eLon eLon VISIBLE NONE"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Tue Jun 12 12:57:06 2012&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Executed (MakeFeatureLayer) successfully.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End Time: Tue Jun 12 12:57:06 2012 (Elapsed Time: 0.00 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know that the select by location should work because when I do it manually in ArcMap, i'm able to select several features through following the similar set of commands but the automation for this step doesn't seem to run.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Variables...
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tableName_e = tableName + str("_e.shp")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tableName_vec = tableName + str("_vec.shp")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tableName_e = tableName + str ("_e.shp")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tableName_sim = tableName + str("_sim.shp")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gate = r"E:\test\gate.shp"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end_lyr = tableName + str("_e.lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vec_lyr = tableName + str("_vec.lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
 # Make a layer from the feature class
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.MakeFeatureLayer_management(gate, "gate_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.MakeFeatureLayer_management(tableName_e, "end_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.MakeFeatureLayer_management(tableName_vec, "vec_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Feature Layers created."

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Selecting the vectors that intersect the gate
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Selecting vectors that intersect the gate for:" + str(tableName)
&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; # Process: Select Layer By Location...
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation_management(vec_lyr, "INTERSECT", gate_lyr, "", "NEW_SELECTION")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Select Layer By Location (2)...
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation_management(end_lyr, "INTERSECT", vec_lyr, "", "ADD_TO_SELECTION")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Select Layer By Location (3)...
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation_management(vec_lyr, "INTERSECT", gate_lyr, "", "REMOVE_FROM_SELECTION")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Write the selected features to a new feature class
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.CopyFeatures_management(end_lyr, tableName_sim,&amp;nbsp; "", "0", "0", "0")


&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:52:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578743#M45361</guid>
      <dc:creator>LarissaPizzolato</dc:creator>
      <dc:date>2021-12-12T00:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Features by Location</title>
      <link>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578744#M45362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Which version of ArcGIS you are on? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please add another print statement in the try block and see whether you get any success message.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation_management(tableName_e_lyr, "intersect", tableName_vec_lyr, "", "ADD_TO_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print gp.GetMessages()
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print gp.GetMessages(2)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:52:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578744#M45362</guid>
      <dc:creator>NobbirAhmed</dc:creator>
      <dc:date>2021-12-12T00:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Features by Location</title>
      <link>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578745#M45363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello NobbirAhmed,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using ArcGIS 9.3.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;when I added the additional print message, and the try/except block this error occured:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing: SelectLayerByLocation 11013_e.lyr INTERSECT 11013_vec.lyr # ADD_TO_SELECTION 11013_e.lyr&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Tue Jun 12 14:18:24 2012&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute. Parameters are not valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000732: Input Feature Layer: Dataset 20041115011426_20041122011013_e.lyr does not exist or is not supported&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000732: Selecting Features: Dataset 20041115011426_20041122011013_vec.lyr does not exist or is not supported&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (SelectLayerByLocation).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2012 17:23:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578745#M45363</guid>
      <dc:creator>LarissaPizzolato</dc:creator>
      <dc:date>2012-06-12T17:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Features by Location</title>
      <link>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578746#M45364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You are referencing layer files that were never created it looks like. MakeFeatureLayer creates a temporary layer in memory, not a layer file.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2012 17:33:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578746#M45364</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-06-12T17:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Features by Location</title>
      <link>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578747#M45365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Mathew!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jun 2012 12:02:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578747#M45365</guid>
      <dc:creator>LarissaPizzolato</dc:creator>
      <dc:date>2012-06-13T12:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Features by Location</title>
      <link>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578739#M45357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Make a layer from the feature class
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.MakeFeatureLayer_management(gate, "gate_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.MakeFeatureLayer_management(tableName_e, "tableName_e_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.MakeFeatureLayer_management(tableName_vec, "tableName_vec_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Feature Layers created."

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Selecting the vectors that intersect the gate
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation_management(tableName_vec_lyr, "intersect", gate_lyr)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add to selection, points that intersect with the previously selected vectors
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation_management(tableName_e_lyr, "intersect", tableName_vec_lyr, "ADD_TO_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove initial vector selection
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByLocation_management(tableName_vec_lyr, "intersect", gate_lyr, "REMOVE_FROM_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Write the selected features to a new feature class
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.CopyFeatures(tableName_e_lyr, tableName_sim)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;The feature layers are successfully created, and the first "select layer by location " works, but it doesn't seem to perform the 2 subsequent "select layer by location"'s.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You need to use the proper syntax.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SelectLayerByLocation_management (in_layer, overlap_type, select_features, search_distance, selection_type) &lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://webhelp.esri.com/arcgisdesktop/9.3/body.cfm?id=1877&amp;amp;pid=1865&amp;amp;topicname=Select%20Layer%20By%20Location%20%28Data%20Management%29&amp;amp;tocVisable=0" rel="nofollow noopener noreferrer" target="_blank"&gt;http://webhelp.esri.com/arcgisdesktop/9.3/body.cfm?id=1877&amp;amp;pid=1865&amp;amp;topicname=Select%20Layer%20By%20Location%20%28Data%20Management%29&amp;amp;tocVisable=0&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are trying to insert "ADD_TO_SELECITON" in the search distance parameter.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:52:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selecting-features-by-location/m-p/578739#M45357</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-12T00:52:17Z</dc:date>
    </item>
  </channel>
</rss>

