<?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 Problem with os.path.join in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/problem-with-os-path-join/m-p/337775#M26493</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am at my wits end on this. I'm using Arc10. Trying to write a script that will loop through a list of feature classes (some shapefiles, some sde files). Eventually I want to add a parameter for the user to input a selection layer, and then have it "select by location" on each feature class and then copy the results to a new layer or shapefile. I've got it mostly to work, however I keep getting an error message when I try to define the output feature class. Relevant portions of the script posted below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Create a list of cliplayers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fcList = [lynxpts, wbc, etsc, svp, Ehplvtrn, Ehrtrn, shbird, iwwh, dwa, lurcdwa, sni, twwh]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#For each layer in the list of cliplayers, select by location according to the input layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#If selection is empty, print a message. If not, copy features to a new layer in the output directory&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for fc in fcList:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; desc = arcpy.Describe(fc)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if desc.extension == "shp":&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; lyr = arcpy.MakeFeatureLayer_management(fc, desc.basename + "_lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; arcpy.SelectLayerByLocation_management(lyr, "INTERSECT", selectlyr, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; count = arcpy.GetCount_management(lyr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if count == 0:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; print "The Selection is empty for " + lyr&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; outFC = os.path.join(outpath, lyr) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CopyFeatures_management(lyr, outFC)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; print "Output Feature Class is: " + outputFC&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The error message in the interactive window is the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: ResultObject: Error in parsing arguments GetOutput&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The error message is referring to the red highlighted line. I don't understand why this isn't working! &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you in advance for any help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Amy Meehan&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wildlife Biologist&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MDIFW&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Bangor, Maine&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Jul 2011 16:32:53 GMT</pubDate>
    <dc:creator>AmyMeehan</dc:creator>
    <dc:date>2011-07-12T16:32:53Z</dc:date>
    <item>
      <title>Problem with os.path.join</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-os-path-join/m-p/337775#M26493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am at my wits end on this. I'm using Arc10. Trying to write a script that will loop through a list of feature classes (some shapefiles, some sde files). Eventually I want to add a parameter for the user to input a selection layer, and then have it "select by location" on each feature class and then copy the results to a new layer or shapefile. I've got it mostly to work, however I keep getting an error message when I try to define the output feature class. Relevant portions of the script posted below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Create a list of cliplayers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fcList = [lynxpts, wbc, etsc, svp, Ehplvtrn, Ehrtrn, shbird, iwwh, dwa, lurcdwa, sni, twwh]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#For each layer in the list of cliplayers, select by location according to the input layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#If selection is empty, print a message. If not, copy features to a new layer in the output directory&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for fc in fcList:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; desc = arcpy.Describe(fc)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if desc.extension == "shp":&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; lyr = arcpy.MakeFeatureLayer_management(fc, desc.basename + "_lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; arcpy.SelectLayerByLocation_management(lyr, "INTERSECT", selectlyr, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; count = arcpy.GetCount_management(lyr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if count == 0:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; print "The Selection is empty for " + lyr&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; outFC = os.path.join(outpath, lyr) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CopyFeatures_management(lyr, outFC)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; print "Output Feature Class is: " + outputFC&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The error message in the interactive window is the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: ResultObject: Error in parsing arguments GetOutput&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The error message is referring to the red highlighted line. I don't understand why this isn't working! &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you in advance for any help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Amy Meehan&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wildlife Biologist&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MDIFW&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Bangor, Maine&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 16:32:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-os-path-join/m-p/337775#M26493</guid>
      <dc:creator>AmyMeehan</dc:creator>
      <dc:date>2011-07-12T16:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with os.path.join</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-os-path-join/m-p/337776#M26494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr = arcpy.MakeFeatureLayer_management(fc, desc.basename + "_lyr")&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It looks like you set lyr to a feature layer object earlier on.&amp;nbsp; The os.path.join is getting caught up on that because it isn't a string.&amp;nbsp; You might want to do &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
outFC = os.path.join(outpath, desc.basename+"_lyr") 
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;instead&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:59:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-os-path-join/m-p/337776#M26494</guid>
      <dc:creator>ChristopherFricke1</dc:creator>
      <dc:date>2021-12-11T15:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with os.path.join</title>
      <link>https://community.esri.com/t5/python-questions/problem-with-os-path-join/m-p/337777#M26495</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;"lyr" is a Result object: &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000000n000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000000n000000.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can't input that directly into os.path.join.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 17:27:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problem-with-os-path-join/m-p/337777#M26495</guid>
      <dc:creator>PhilMorefield</dc:creator>
      <dc:date>2011-07-12T17:27:48Z</dc:date>
    </item>
  </channel>
</rss>

