<?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.SelectLayerByLocation_management not working in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297544#M22996</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, it worked!&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Aug 2019 15:53:49 GMT</pubDate>
    <dc:creator>JessicaRamirez1</dc:creator>
    <dc:date>2019-08-20T15:53:49Z</dc:date>
    <item>
      <title>arcpy.SelectLayerByLocation_management not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297537#M22989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am new to python and arcpy, I have a script I am trying to get to work. It fails at the select layer by location. If I take out the select by location the script runs fine and the field calculates works. I feel like I am missing something simple but I just don't know.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #cc7832;"&gt;import &lt;/SPAN&gt;arcpy
&lt;SPAN style="color: #808080;"&gt;# Set the workspace environment
&lt;/SPAN&gt;arcpy.env.workspace = &lt;SPAN style="color: #a5c261;"&gt;r"G:\GIS\ESRI\Staging\Survey123\Testing\New File Geodatabase.gdb"
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;print &lt;/SPAN&gt;arcpy.ListFeatureClasses()
&lt;SPAN style="color: #cc7832;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #a5c261;"&gt;"this is a list of feature classes"&lt;/SPAN&gt;)
&lt;SPAN style="color: #808080;"&gt;# Select by location
&lt;/SPAN&gt;arcpy.SelectLayerByLocation_management(&lt;SPAN style="color: #a5c261;"&gt;"propertypnts"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;"INTERSECT"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;"retailpt2"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;""&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;"NEW_SELECTION"&lt;/SPAN&gt;)
&lt;SPAN style="color: #cc7832;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #a5c261;"&gt;"I have selected the features"&lt;/SPAN&gt;)
&lt;SPAN style="color: #808080;"&gt;# Field Calculate
&lt;/SPAN&gt;arcpy.CalculateField_management(&lt;SPAN style="color: #a5c261;"&gt;'propertypnts'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;"CompleteY_N"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;                                &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;'!CompleteY_N!.replace("Not Completed","Completed")'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;"Python_9.3"&lt;/SPAN&gt;)
&lt;SPAN style="color: #cc7832;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #a5c261;"&gt;"Calculation done"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;This is the error I get.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt; File "G:/GIS/ESRI/Staging/Survey123/Testing/SelectCalculate.py", line 8, in &amp;lt;module&amp;gt;&lt;BR /&gt; arcpy.SelectLayerByLocation_management("propertypnts", "INTERSECT", "retailpt2", "", "NEW_SELECTION")&lt;BR /&gt; File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\management.py", line 7891, in SelectLayerByLocation&lt;BR /&gt; raise e&lt;BR /&gt;arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.&lt;BR /&gt;ERROR 000368: Invalid input data.&lt;BR /&gt;Failed to execute (SelectLayerByLocation)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Python&amp;nbsp;&lt;A href="https://community.esri.com/t5/tag/arcpy/tg-p" target="_blank"&gt;#arcpy&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:16:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297537#M22989</guid>
      <dc:creator>JessicaRamirez1</dc:creator>
      <dc:date>2021-12-11T14:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.SelectLayerByLocation_management not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297538#M22990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try dropping the last 2 parameters ( ie "", "NEW_SELECTION").&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2019 20:34:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297538#M22990</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-08-19T20:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.SelectLayerByLocation_management not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297539#M22991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;Thank You for your reply. Unfortunately, I get the same error as before even if I drop the last 2 parameters. No idea what to do now.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2019 20:48:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297539#M22991</guid>
      <dc:creator>JessicaRamirez1</dc:creator>
      <dc:date>2019-08-19T20:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.SelectLayerByLocation_management not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297540#M22992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The code snippet you provided isn't self contained, i.e., it relies on additional code we cannot see to be complete.&amp;nbsp; For example, where are you defining or making the "propertypnts" and "retailpt2" ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2019 21:02:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297540#M22992</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-08-19T21:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.SelectLayerByLocation_management not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297541#M22993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is a good question, they are in my geodatabase from my workspace. How do I define them?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2019 21:31:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297541#M22993</guid>
      <dc:creator>JessicaRamirez1</dc:creator>
      <dc:date>2019-08-19T21:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.SelectLayerByLocation_management not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297542#M22994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to use the &lt;EM&gt;make featurelayer&lt;/EM&gt; tool to expose them as layer objects that can feed into the select by location tool. Have a look at the help file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Aug 2019 14:13:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297542#M22994</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2019-08-20T14:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.SelectLayerByLocation_management not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297543#M22995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming "they" are feature classes, you need to use &lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/make-feature-layer.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/make-feature-layer.htm"&gt;Make Feature Layer—Help | ArcGIS Desktop&lt;/A&gt; to define them as layers.&amp;nbsp; See the code sample on the documentation for the general workflow.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Aug 2019 14:24:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297543#M22995</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-08-20T14:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.SelectLayerByLocation_management not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297544#M22996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, it worked!&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Aug 2019 15:53:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297544#M22996</guid>
      <dc:creator>JessicaRamirez1</dc:creator>
      <dc:date>2019-08-20T15:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.SelectLayerByLocation_management not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297545#M22997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you! it worked!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Aug 2019 15:54:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297545#M22997</guid>
      <dc:creator>JessicaRamirez1</dc:creator>
      <dc:date>2019-08-20T15:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.SelectLayerByLocation_management not working</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297546#M22998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please mark one of our answers correct.&amp;nbsp; Since Duncan beat me to the punchline, maybe mark his correct and mine helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Aug 2019 16:15:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-selectlayerbylocation-management-not-working/m-p/297546#M22998</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-08-20T16:15:20Z</dc:date>
    </item>
  </channel>
</rss>

