<?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: crash when using SelectLayerByLocation in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/crash-when-using-selectlayerbylocation/m-p/1102306#M62546</link>
    <description>&lt;P&gt;changing the first couple lines to use path.join instead of just directly typing it in and wrapping the entire thing in a try except block seemed to have no effect on the result... including oddly enough the except part of the try except not firing. it seems like whatever the crash is kills the program without allowing error handling.&lt;/P&gt;&lt;P&gt;it also occurs to me that I have been able to use the same declaration for the roadlayer in other functions like CopyFeatures without error, so the path itself should be fine&lt;/P&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Sep 2021 21:26:28 GMT</pubDate>
    <dc:creator>GavinPaw</dc:creator>
    <dc:date>2021-09-27T21:26:28Z</dc:date>
    <item>
      <title>crash when using SelectLayerByLocation</title>
      <link>https://community.esri.com/t5/python-questions/crash-when-using-selectlayerbylocation/m-p/1102283#M62544</link>
      <description>&lt;P&gt;I am attempting to use arcpy.SelectLayerByLocation_management() to select polyline objects on a given layer based on their relationship to a point, but any time I run the code outside of Arcgis (in PyCharm) it results in a crash where an ESRI error report box pops up with nothing printed to console that I can see.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;arcpy&lt;BR /&gt;&lt;BR /&gt;projRoot = arcpy.mp.ArcGISProject(&lt;SPAN&gt;"./dat/project/project.aprx"&lt;/SPAN&gt;)&lt;BR /&gt;mainMap = projRoot.listMaps(&lt;SPAN&gt;"Map"&lt;/SPAN&gt;)[&lt;SPAN&gt;0&lt;/SPAN&gt;]&lt;BR /&gt;&lt;BR /&gt;roadLayer = mainMap.listLayers(&lt;SPAN&gt;"story_county_roads"&lt;/SPAN&gt;)[&lt;SPAN&gt;0&lt;/SPAN&gt;]&lt;BR /&gt;&lt;BR /&gt;arcpy.SelectLayerByLocation_management(roadLayer&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"CONTAINS"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;arcpy.PointGeometry(arcpy.Point(&lt;SPAN&gt;461715.4856701&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;4656029.4532028&lt;/SPAN&gt;)))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;the above is the entirety of a minimized file I created to test the error and seems to run fine when pasted into an instance of Arcgis Pro using "CURRENT" instead of a path for the project, however using the path still results in a crash even when running in Arcgis. what would be the proper way to use select layer by location externally if the above is broken?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Sep 2021 20:34:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/crash-when-using-selectlayerbylocation/m-p/1102283#M62544</guid>
      <dc:creator>GavinPaw</dc:creator>
      <dc:date>2021-09-27T20:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: crash when using SelectLayerByLocation</title>
      <link>https://community.esri.com/t5/python-questions/crash-when-using-selectlayerbylocation/m-p/1102291#M62545</link>
      <description>&lt;P&gt;It sounds like your path might be incorrect if it crashes inside ArcGIS with a specific path. I normally do something like this to use a relative path.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;path = os.path.join(os.getcwd(), 'dat', 'project', 'project.aprx')
projRoot = arcpy.mp.ArcGISProject(path)&lt;/LI-CODE&gt;&lt;P&gt;Try wrapping the whole thing in a try/except statement (print the exception) to see what the issue might be.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Sep 2021 20:55:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/crash-when-using-selectlayerbylocation/m-p/1102291#M62545</guid>
      <dc:creator>nzjs</dc:creator>
      <dc:date>2021-09-27T20:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: crash when using SelectLayerByLocation</title>
      <link>https://community.esri.com/t5/python-questions/crash-when-using-selectlayerbylocation/m-p/1102306#M62546</link>
      <description>&lt;P&gt;changing the first couple lines to use path.join instead of just directly typing it in and wrapping the entire thing in a try except block seemed to have no effect on the result... including oddly enough the except part of the try except not firing. it seems like whatever the crash is kills the program without allowing error handling.&lt;/P&gt;&lt;P&gt;it also occurs to me that I have been able to use the same declaration for the roadlayer in other functions like CopyFeatures without error, so the path itself should be fine&lt;/P&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Sep 2021 21:26:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/crash-when-using-selectlayerbylocation/m-p/1102306#M62546</guid>
      <dc:creator>GavinPaw</dc:creator>
      <dc:date>2021-09-27T21:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: crash when using SelectLayerByLocation</title>
      <link>https://community.esri.com/t5/python-questions/crash-when-using-selectlayerbylocation/m-p/1102423#M62547</link>
      <description>&lt;P&gt;Without an instantiated project, I don't know if you can use layers in this way. Running Select Layer By Location from a standalone script seems to imply you have a project session going.&amp;nbsp; Using a layer as input to Copy Features is different from modifying selection status the layer. If you run &lt;STRIKE&gt;Create&lt;/STRIKE&gt; Make Feature Layer to instantiate&amp;nbsp; a layer in memory, will &lt;EM&gt;that&lt;/EM&gt; layer work with select Layer by Location?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 22:30:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/crash-when-using-selectlayerbylocation/m-p/1102423#M62547</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-09-28T22:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: crash when using SelectLayerByLocation</title>
      <link>https://community.esri.com/t5/python-questions/crash-when-using-selectlayerbylocation/m-p/1102839#M62561</link>
      <description>&lt;P&gt;the function ended up being named MakeFeatureLayer but it worked, passing in roadLayer from above returned something that is able to be used&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 22:22:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/crash-when-using-selectlayerbylocation/m-p/1102839#M62561</guid>
      <dc:creator>GavinPaw</dc:creator>
      <dc:date>2021-09-28T22:22:25Z</dc:date>
    </item>
  </channel>
</rss>

