<?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 Python - select layer by location. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-select-layer-by-location/m-p/501853#M39406</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I am looking for help correcting my python script. I am having trouble with the select layer by location from a buffer feature layer. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 May 2015 16:13:54 GMT</pubDate>
    <dc:creator>AlexanderHaussman</dc:creator>
    <dc:date>2015-05-11T16:13:54Z</dc:date>
    <item>
      <title>Python - select layer by location.</title>
      <link>https://community.esri.com/t5/python-questions/python-select-layer-by-location/m-p/501853#M39406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I am looking for help correcting my python script. I am having trouble with the select layer by location from a buffer feature layer. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 May 2015 16:13:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-select-layer-by-location/m-p/501853#M39406</guid>
      <dc:creator>AlexanderHaussman</dc:creator>
      <dc:date>2015-05-11T16:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Python - select layer by location.</title>
      <link>https://community.esri.com/t5/python-questions/python-select-layer-by-location/m-p/501854#M39407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000072000000" rel="nofollow noopener noreferrer" target="_blank"&gt;help page&lt;/A&gt;. Look at the example. Note the quotes, particularly around the overlap type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, please review &lt;A href="https://www.google.ca/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=0CB0QFjAA&amp;amp;url=https%3A%2F%2Fgeonet.esri.com%2Fpeople%2Fcurtvprice%2Fblog%2F2014%2F09%2F25%2Fposting-code-blocks-in-the-new-geonet&amp;amp;ei=ptlQVYquKsnboATA2IGADw&amp;amp;usg=AFQjCNHnDCRN9M7wRcjRvA8q_IMRum1F4w&amp;amp;sig2=d9oWbyptPhoPIGenWpZV_A&amp;amp;bvm=bv.92885102,d.cGU" rel="nofollow noopener noreferrer" target="_blank"&gt;how to post code blocks on GeoNet&lt;/A&gt; so we don't have to download a potentially harmful Python script. Here is the uncorrected script, for future reference:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os

arcpy.env.workspace = "F:\\GEO443\\Final"
arcpy.env.overwriteOutput = True

brown = "F:\\GEO443\\Final\\BRO_ADDS\\BRO_ADDS.shp"
green = "F:\\GEO443\\Final\\GRE_ADDS\\GRE_ADDS.shp"
hancock = "F:\\GEO443\\Final\\HAN_ADDS\\HAN_ADDS.shp"
logan = "F:\\GEO443\\Final\\LOG_ADDS\\LOG_ADDS.shp" 
muskingum = "F:\\GEO443\\Final\\MUS_ADDS\\MUS_ADDS.shp"

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; ## CreateFileGDB_management (out_folder_path, out_name, {out_version})
&amp;nbsp;&amp;nbsp;&amp;nbsp; ## execute create file .gdb
&amp;nbsp;&amp;nbsp;&amp;nbsp; #arcpy.CreateFileGDB_management("F:\\GEO443\\Final","county.gdb")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "file GDB created"
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; ##FeatureClassToGeodatabase_conversion (Input_Features, Output_Geodatabase)
&amp;nbsp;&amp;nbsp;&amp;nbsp; #arcpy.FeatureClassToGeodatabase_conversion([brown,green,hancock,logan,muskingum],"F:\\GEO443\\Final\\county.gdb")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "shape files moved to gdb"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.overwriteOutput = True 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = "F:\\GEO443\\Final\\county.gdb"

&amp;nbsp;&amp;nbsp;&amp;nbsp; kroger_selection = ('"COMMENT" = \'KROGER\'')&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs = arcpy.ListFeatureClasses()
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fc
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print ""
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fc_kroger = fc + "kroger"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fc_lyr = arcpy.MakeFeatureLayer_management(fc,fc_kroger)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Feature layer created"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## SelectLayerByAttribute_management (in_layer_or_view, {selection_type}, {where_clause})
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(fc_lyr,"NEW_SELECTION",kroger_selection)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(fc_lyr,fc + "krogerselection")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Kroger Selected"

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## Buffer_analysis (in_features, out_feature_class, buffer_distance_or_field, {line_side}, {line_end_type}, {dissolve_option}, {dissolve_field})
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs = arcpy.ListFeatureClasses("*krogerselection")
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fc
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Buffer_analysis(fc, fc + "Buff", "1 Mile")
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Features Copied"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Buffer Created"

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## SelectLayerByLocation_management (in_layer, {overlap_type}, {select_features}, {search_distance}, {selection_type})&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs = arcpy.ListFeatureClasses("*krogerselection")
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fc
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fc_location = fc + "location"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fc_Addr = arcpy.MakeFeatureLayer_management(fc, fc_location)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "location fc created"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(fc_Addr, WITHIN, fc + "Buff")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(fc_Addr, fc + "addresses")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "addresses selected" 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages(2)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Apparently, &lt;A _jive_internal="true" href="https://community.esri.com/message/517199#517199" target="_blank"&gt;this is a hard assignment&lt;/A&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:01:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-select-layer-by-location/m-p/501854#M39407</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-11T22:01:17Z</dc:date>
    </item>
  </channel>
</rss>

