<?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 Error Message Select By Attribute in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-message-select-by-attribute/m-p/22619#M1756</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm getting an error message in my Select by Attribute statement saying the layer file doesn't exist, however, the output of the Make Feature Layer completed successfully. Thoughts?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
fc = arcpy.ListFeatureClasses()
for f in fc:

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Run Viewshed
&amp;nbsp;&amp;nbsp;&amp;nbsp; outViewshed = ViewshedRasters+"/"+"view_"+f[6:].split(".")[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Viewshed_3d(Elevation,f, outViewshed,1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()

&amp;nbsp;&amp;nbsp;&amp;nbsp; #convert viewshed to polygon
&amp;nbsp;&amp;nbsp;&amp;nbsp; OutPoly = ViewshedPolys+"/"+os.path.basename(outViewshed).split(".")[0]+"_poly.shp"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RasterToPolygon_conversion(outViewshed,OutPoly)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(OutPoly,"COUNT","SHORT")
&amp;nbsp;&amp;nbsp;&amp;nbsp; OutPolyLyr = OutPoly.split(".")[0]+"_Lyr"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(OutPoly,OutPolyLyr)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()
&amp;nbsp;&amp;nbsp;&amp;nbsp; WhereClause = '"COUNT" = \'1\''
&amp;nbsp;&amp;nbsp;&amp;nbsp; print WhereClause
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(OutPolyLyr,"NEW_SELECTION",WhereClause)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()
&amp;nbsp;&amp;nbsp;&amp;nbsp; view = arcpy.GetCount_management(OutPolyLyr)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "There are",view,"selected"
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Output from Make Feature Layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
Executing: MakeFeatureLayer C:/ArcGIS/SurfCityData/Scratch/ViewshedPolys/view_0_poly.shp C:/ArcGIS/SurfCityData/Scratch/ViewshedPolys/view_0_poly_Lyr # # "FID FID VISIBLE NONE;Shape Shape VISIBLE NONE;ID ID VISIBLE NONE;GRIDCODE GRIDCODE VISIBLE NONE;COUNT COUNT VISIBLE NONE"
Start Time: Sun Sep 22 09:41:28 2013
Succeeded at Sun Sep 22 09:41:28 2013 (Elapsed Time: 0.00 seconds)
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Error Message&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
Traceback (most recent call last):
&amp;nbsp; File "C:\Python27\ArcGIS10.1\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
&amp;nbsp;&amp;nbsp;&amp;nbsp; exec codeObject in __main__.__dict__
&amp;nbsp; File "C:\ArcGIS\SurfCityData\Code\SC_ViewShed.py", line 127, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(OutPolyLyr,"NEW_SELECTION",WhereClause)
&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 6435, in SelectLayerByAttribute
&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Layer Name or Table View: Dataset C:/ArcGIS/SurfCityData/Scratch/ViewshedPolys/view_0_poly_Lyr does not exist or is not supported
Failed to execute (SelectLayerByAttribute).
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 22 Sep 2013 12:56:57 GMT</pubDate>
    <dc:creator>RachelAlbritton</dc:creator>
    <dc:date>2013-09-22T12:56:57Z</dc:date>
    <item>
      <title>Error Message Select By Attribute</title>
      <link>https://community.esri.com/t5/python-questions/error-message-select-by-attribute/m-p/22619#M1756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm getting an error message in my Select by Attribute statement saying the layer file doesn't exist, however, the output of the Make Feature Layer completed successfully. Thoughts?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
fc = arcpy.ListFeatureClasses()
for f in fc:

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Run Viewshed
&amp;nbsp;&amp;nbsp;&amp;nbsp; outViewshed = ViewshedRasters+"/"+"view_"+f[6:].split(".")[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Viewshed_3d(Elevation,f, outViewshed,1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()

&amp;nbsp;&amp;nbsp;&amp;nbsp; #convert viewshed to polygon
&amp;nbsp;&amp;nbsp;&amp;nbsp; OutPoly = ViewshedPolys+"/"+os.path.basename(outViewshed).split(".")[0]+"_poly.shp"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RasterToPolygon_conversion(outViewshed,OutPoly)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(OutPoly,"COUNT","SHORT")
&amp;nbsp;&amp;nbsp;&amp;nbsp; OutPolyLyr = OutPoly.split(".")[0]+"_Lyr"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(OutPoly,OutPolyLyr)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()
&amp;nbsp;&amp;nbsp;&amp;nbsp; WhereClause = '"COUNT" = \'1\''
&amp;nbsp;&amp;nbsp;&amp;nbsp; print WhereClause
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(OutPolyLyr,"NEW_SELECTION",WhereClause)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()
&amp;nbsp;&amp;nbsp;&amp;nbsp; view = arcpy.GetCount_management(OutPolyLyr)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "There are",view,"selected"
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Output from Make Feature Layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
Executing: MakeFeatureLayer C:/ArcGIS/SurfCityData/Scratch/ViewshedPolys/view_0_poly.shp C:/ArcGIS/SurfCityData/Scratch/ViewshedPolys/view_0_poly_Lyr # # "FID FID VISIBLE NONE;Shape Shape VISIBLE NONE;ID ID VISIBLE NONE;GRIDCODE GRIDCODE VISIBLE NONE;COUNT COUNT VISIBLE NONE"
Start Time: Sun Sep 22 09:41:28 2013
Succeeded at Sun Sep 22 09:41:28 2013 (Elapsed Time: 0.00 seconds)
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Error Message&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
Traceback (most recent call last):
&amp;nbsp; File "C:\Python27\ArcGIS10.1\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
&amp;nbsp;&amp;nbsp;&amp;nbsp; exec codeObject in __main__.__dict__
&amp;nbsp; File "C:\ArcGIS\SurfCityData\Code\SC_ViewShed.py", line 127, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(OutPolyLyr,"NEW_SELECTION",WhereClause)
&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 6435, in SelectLayerByAttribute
&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Layer Name or Table View: Dataset C:/ArcGIS/SurfCityData/Scratch/ViewshedPolys/view_0_poly_Lyr does not exist or is not supported
Failed to execute (SelectLayerByAttribute).
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Sep 2013 12:56:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-message-select-by-attribute/m-p/22619#M1756</guid>
      <dc:creator>RachelAlbritton</dc:creator>
      <dc:date>2013-09-22T12:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: Error Message Select By Attribute</title>
      <link>https://community.esri.com/t5/python-questions/error-message-select-by-attribute/m-p/22620#M1757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As far as I know the MakeFeatureLayer tool just creates a temporary layer for use within the current tool or mxd and does not save it to disc (copy features will do this if needed) and therefore your "OutPolyLyr" does not actually exist in your "C:/ArcGIS/SurfCityData/Scratch/ViewshedPolys" folder and the Select by attribute tool cannot find it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you remove or comment out the &lt;/SPAN&gt;&lt;STRONG&gt;OutPolyLyr = OutPoly.split(".")[0]+"_Lyr"&lt;/STRONG&gt;&lt;SPAN&gt; line from your script then I think it should work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thnaks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Sep 2013 17:17:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-message-select-by-attribute/m-p/22620#M1757</guid>
      <dc:creator>TimDonoyou</dc:creator>
      <dc:date>2013-09-22T17:17:12Z</dc:date>
    </item>
  </channel>
</rss>

