<?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: Issues with feature layers and python in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/issues-with-feature-layers-and-python/m-p/343890#M19608</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jake,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you, that solved that little hangup. The lock issue was my own fault, it was because I made my cursor an update cursor which locked the table I was trying to select features from. Thanks again for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Jan 2015 16:44:02 GMT</pubDate>
    <dc:creator>ThomasCaruso</dc:creator>
    <dc:date>2015-01-06T16:44:02Z</dc:date>
    <item>
      <title>Issues with feature layers and python</title>
      <link>https://community.esri.com/t5/data-management-questions/issues-with-feature-layers-and-python/m-p/343888#M19606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey folks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pretty new to GIS and scripting (in any language) and I'm trying to write a program that will, basically:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) look at a point that represents an unverified well location&lt;/P&gt;&lt;P&gt;2) search for all centroids within a certain distance and select them&lt;/P&gt;&lt;P&gt;3) compare the last name of the well owner with the last name of all selected centroid owners&lt;/P&gt;&lt;P&gt;4) if there is a match between any, put "yes" in a "match" column&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are the issues I'm having:&lt;/P&gt;&lt;P&gt;1) the arcpy.SelectLayerByLocation function requires a feature layer input. I added a line in my script that makes my centroid data into a feature layer, which actually creates a layer in my table of contents, and when I fix an error and try to run the script again, it stops almost immediately saying that the feature layer already exists. If I take it out of the script, then the feature layer is undefined for later. My supervisor (who has a good amount of GIS experience) says something is happening weirdly there and is unsure why.&lt;/P&gt;&lt;P&gt;2) lock issues. Every time I try to run it and it gets past the feature layer part, I get this error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Runtime error&amp;nbsp; Traceback (most recent call last):&amp;nbsp;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 17, in &amp;lt;module&amp;gt;&amp;nbsp;&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 6618, in SelectLayerByLocation&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e ExecuteError: ERROR 999999: Error executing function. Cannot acquire a lock. Cannot acquire a lock. Item not found in this collection. Failed to execute (SelectLayerByLocation).&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone point me in the right direction here?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code I've written&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
# define a workspace
arcpy.env.workspace = r"C:\Users\tmc18\Desktop\comp_orps\NYS_Wells.gdb"
# Define input files
orps = r"C:\Users\tmc18\Desktop\comp_orps\centroids\madirps_point1.shp"
wells = r"C:\Users\tmc18\Desktop\comp_orps\NYS_Wells.gdb\Madison_DEC_Well_Logs_3_14_14_MASTER_COPY1"
arcpy.MakeFeatureLayer_management(orps, "orpsFL")
# Create well update cursor, will compare the "owner_last" field value of the well used to select nearby centroids to the "owner_last"
# field of centroid data. 
with arcpy.da.UpdateCursor(wells, ["match", "owner_last"]) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management("orpsFL", "WITHIN_A_DISTANCE", wells, "0.5 kilometers", "new_selection")
&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; # create orps name cursor
&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; orps_match = arcpy.da.SearchCursor("orpsFL", ["owner_last"])
&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; # if the uppercase string value of the well owner's last name != the centroid, then the orps_match cursor will move to the next
&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; # centroid name and try that one.
&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; if str([row[1] for row in cursor]).upper != str([row[0] for row in orps_match]).upper:
&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; orps_match.next
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; # but if they do match, we get a "yes" in the match column
&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; else:
&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; row[0] = "YES"
&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; cursor.updateRow(row)
&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; continue&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:12:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/issues-with-feature-layers-and-python/m-p/343888#M19606</guid>
      <dc:creator>ThomasCaruso</dc:creator>
      <dc:date>2021-12-11T16:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with feature layers and python</title>
      <link>https://community.esri.com/t5/data-management-questions/issues-with-feature-layers-and-python/m-p/343889#M19607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Thomas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can add the following line below you 'import arcpy' statement to overwrite any output layers, in this case your Feature Layer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14200582091068802" jivemacro_uid="_14200582091068802"&gt;&lt;P&gt;arcpy.env.overwriteOutput = 1&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See if that will help with the lock issue you are receiving as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Dec 2014 20:37:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/issues-with-feature-layers-and-python/m-p/343889#M19607</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2014-12-31T20:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with feature layers and python</title>
      <link>https://community.esri.com/t5/data-management-questions/issues-with-feature-layers-and-python/m-p/343890#M19608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jake,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you, that solved that little hangup. The lock issue was my own fault, it was because I made my cursor an update cursor which locked the table I was trying to select features from. Thanks again for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jan 2015 16:44:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/issues-with-feature-layers-and-python/m-p/343890#M19608</guid>
      <dc:creator>ThomasCaruso</dc:creator>
      <dc:date>2015-01-06T16:44:02Z</dc:date>
    </item>
  </channel>
</rss>

