<?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 000732 when trying to run MakeFeatureLayer in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-000732-when-trying-to-run-makefeaturelayer/m-p/285057#M22013</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am fairly new to Python, so bear with me. I am writing a script which loops through a folder containing multiple rasters, and exports polygons from the rasters.&amp;nbsp; I have gotten the script to reclassify cells using 'Slice', and can output shapefiles, but when I try to MakeFeatureLayer(i need to do this to select certain polygons) from the shapefile it is giving me error 000732 which says the shapefile doesn't exist.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is a snippet from the code....I just cant get it to recognize that the shapefile does indeed exist.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
import arcpy
from arcpy import env

arcpy.env.workspace = arcpy.GetParameterAsText(0)

arcpy.CheckOutExtension("3D")

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs = arcpy.ListRasters()

&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = "reclass_" + fc

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Reclassify's raster cells
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Slice_3d(fc, outRaster, 2, "EQUAL_INTERVAL")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outShp = fc.strip(".tif")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #converts raster to polygon shapefile
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RasterToPolygon_conversion(outRaster, outShp, "SIMPLIFY", "VALUE" )&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outLyr = outShp + "_lyr"

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #make layer from shapefile so I can select by attribute
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(outShp, outLyr)
&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.SelectLayerByAttribute_management(outLyr, "NEW_SELECTION", ' "GRIDCODE" = 1 ')
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for any help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Sep 2012 20:47:42 GMT</pubDate>
    <dc:creator>RileyCotter</dc:creator>
    <dc:date>2012-09-27T20:47:42Z</dc:date>
    <item>
      <title>Error 000732 when trying to run MakeFeatureLayer</title>
      <link>https://community.esri.com/t5/python-questions/error-000732-when-trying-to-run-makefeaturelayer/m-p/285057#M22013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am fairly new to Python, so bear with me. I am writing a script which loops through a folder containing multiple rasters, and exports polygons from the rasters.&amp;nbsp; I have gotten the script to reclassify cells using 'Slice', and can output shapefiles, but when I try to MakeFeatureLayer(i need to do this to select certain polygons) from the shapefile it is giving me error 000732 which says the shapefile doesn't exist.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is a snippet from the code....I just cant get it to recognize that the shapefile does indeed exist.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
import arcpy
from arcpy import env

arcpy.env.workspace = arcpy.GetParameterAsText(0)

arcpy.CheckOutExtension("3D")

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs = arcpy.ListRasters()

&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = "reclass_" + fc

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Reclassify's raster cells
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Slice_3d(fc, outRaster, 2, "EQUAL_INTERVAL")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outShp = fc.strip(".tif")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #converts raster to polygon shapefile
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RasterToPolygon_conversion(outRaster, outShp, "SIMPLIFY", "VALUE" )&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outLyr = outShp + "_lyr"

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #make layer from shapefile so I can select by attribute
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(outShp, outLyr)
&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.SelectLayerByAttribute_management(outLyr, "NEW_SELECTION", ' "GRIDCODE" = 1 ')
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for any help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 20:47:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-000732-when-trying-to-run-makefeaturelayer/m-p/285057#M22013</guid>
      <dc:creator>RileyCotter</dc:creator>
      <dc:date>2012-09-27T20:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: Error 000732 when trying to run MakeFeatureLayer</title>
      <link>https://community.esri.com/t5/python-questions/error-000732-when-trying-to-run-makefeaturelayer/m-p/285058#M22014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Please read.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/48475-Please-read-How-to-post-Python-code"&gt;http://forums.arcgis.com/threads/48475-Please-read-How-to-post-Python-code&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is it your "outShp" variable it is saying does not exist?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 20:51:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-000732-when-trying-to-run-makefeaturelayer/m-p/285058#M22014</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-09-27T20:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: Error 000732 when trying to run MakeFeatureLayer</title>
      <link>https://community.esri.com/t5/python-questions/error-000732-when-trying-to-run-makefeaturelayer/m-p/285059#M22015</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry about that....Yes it is the outShp variable that the script doesn't recognize&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 20:54:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-000732-when-trying-to-run-makefeaturelayer/m-p/285059#M22015</guid>
      <dc:creator>RileyCotter</dc:creator>
      <dc:date>2012-09-27T20:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: Error 000732 when trying to run MakeFeatureLayer</title>
      <link>https://community.esri.com/t5/python-questions/error-000732-when-trying-to-run-makefeaturelayer/m-p/285060#M22016</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Sorry about that....Yes it is the outShp variable that the script doesn't recognize&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I would imagine you are looking for an actual shapefile (.shp) to create the feature layer from? Or did you create a feature class in a&amp;nbsp; geodatabase?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd try something like this, probably not really needed depending on your needs, but you should be able to adapt to your purposes if the output type/extension is the issue you are indeed having.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

outWorkspace = arcpy.GetParameterAsText(0)

arcpy.env.workspace = outWorkspace

arcpy.CheckOutExtension("3D")

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs = arcpy.ListRasters()

&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = "reclass_" + fc

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Reclassify's raster cells
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Slice_3d(fc, outRaster, 2, "EQUAL_INTERVAL")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outShp = fc.strip(".tif")

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if outWorkspace.endswith(".gdb"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output_type = "FGDB"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output = os.path.join(outWorkspace, "%s" % outShp)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif outWorkspace.endswith(".mdb"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output_type = "PGDB"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output = os.path.join(outWorkspace, "%s" % outShp)

&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; output_type = "SHP"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output = os.path.join(outWorkspace, "%s.shp" % outShp)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #converts raster to polygon shapefile
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RasterToPolygon_conversion(outRaster, output, "SIMPLIFY", "VALUE" )

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outLyr = outShp + "_lyr"

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #make layer from shapefile so I can select by attribute
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(outShp, outLyr)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(outLyr, "NEW_SELECTION", ' "GRIDCODE" = 1 ')&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:47:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-000732-when-trying-to-run-makefeaturelayer/m-p/285060#M22016</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T13:47:15Z</dc:date>
    </item>
  </channel>
</rss>

