<?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: Trouble deleting feature layer in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81152#M2824</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sorry, I don't see how to put it in code tags, but here is the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rows = gp.SearchCursor(workspace + "\\parcels_ut_town_list.dbf")&lt;/P&gt;&lt;P&gt;for row in rows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; town = row.town&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create Output Directory&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; towndir = town.strip()&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create Output Directory&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Processing" + " " + town)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Processing" + " " + town&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Creating Directory For" + " " + town)&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "creating outfolder for "+town&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outfolder = gp.CreateFolder_management(workspace, towndir)&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; ##Sometimes quitting here&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; expression = "TOWN = " + "'" + town.strip() + "'"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; parcels = outfolder + "\\parcels"+towndir+".kmz"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Make Feature Layer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "making feature layer"&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;&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; ##-And sometimes quitting around the next line-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(parcelsProject_shp, parcelsProject_Layer, expression, "", "FID FID VISIBLE NONE;TOWN TOWN VISIBLE NONE;COUNTY COUNTY VISIBLE NONE;GEOCODE GEOCODE VISIBLE NONE;STATE_ID STATE_ID VISIBLE NONE;MAP_BK_LOT MAP_BK_LOT VISIBLE NONE;PARENT PARENT VISIBLE NONE;PROP_LOC PROP_LOC VISIBLE NONE;PROPLOCNUM PROPLOCNUM VISIBLE NONE;TYPE TYPE VISIBLE NONE;FMUPDORG FMUPDORG VISIBLE NONE;FMUPDAT FMUPDAT VISIBLE NONE;FMSRCORG FMSRCORG VISIBLE NONE;Shape_STAr Shape_STAr VISIBLE NONE;Shape_STLe Shape_STLe VISIBLE NONE;Shape Shape VISIBLE NONE;Shape_ST_1 Shape_ST_1 HIDDEN NONE;Shape_ST_2 Shape_ST_2 HIDDEN NONE")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Layer To KML&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Converting town to KML")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Converting town to KML"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.LayerToKML_conversion(parcelsProject_Layer, parcels, "0", "false", parcelsProject_Layer, "1024", "96", "CLAMPED_TO_GROUND")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Copy Metadata&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Copying parcels Metadata For" + " " + town)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Copying parcels Metadata For" + " " + town&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; shutil.copy(metat, outfolder + "\\" + "parcels.txt")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Done Processing parcels For" + " " + town)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Done Processing parcels For" + " " + town&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Create The Zipfile&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #gp.AddMessage(output + "\\Parcels_" + towndir)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; zpfile = zipfile.ZipFile(output + "\\Parcels_" + towndir + ".zip", 'w')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; zpfile.write(outfolder + "\\parcels"+towndir+".kmz", "Parcels_" + towndir + ".kmz", zipfile.ZIP_DEFLATED)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; zpfile.write(outfolder + "\\parcels.txt", "Parcels_" + towndir + ".txt", zipfile.ZIP_DEFLATED)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; zpfile.close()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Delete Uncompressed Files&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; shutil.rmtree(outfolder)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("All Done Processing" + " " + town)&lt;/P&gt;&lt;P&gt;del rows&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Jan 2016 14:42:44 GMT</pubDate>
    <dc:creator>BobBistrais</dc:creator>
    <dc:date>2016-01-08T14:42:44Z</dc:date>
    <item>
      <title>Trouble deleting feature layer</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81148#M2820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working on a Python script that includes a cursor looping process to create KML files for individual towns.&amp;nbsp; For each iteration of the loop, the script creates a feature layer, then exports that feature layer to KML.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is, the script tends to stop working for no apparent reason.&amp;nbsp; After each KML is created from the feature layer, I delete the feature layer so a new one can be created for the next town.&amp;nbsp; The script tends to stop at this point.&amp;nbsp; No error messages, and it doesn't stop at the same town every time I try.&amp;nbsp; Here is the code that manipulates the feature layer:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Deleting feature layer..."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(parcelsProject_Layer)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "...deleted it"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; except:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Couldn't delete feature layer!", sys.exc_info()[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else: &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Make Feature Layer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(parcelsProject_shp, parcelsProject_Layer, expression, "", "FID FID VISIBLE NONE;TOWN TOWN VISIBLE NONE;COUNTY COUNTY VISIBLE NONE;GEOCODE GEOCODE VISIBLE NONE;STATE_ID STATE_ID VISIBLE NONE;MAP_BK_LOT MAP_BK_LOT VISIBLE NONE;PARENT PARENT VISIBLE NONE;PROP_LOC PROP_LOC VISIBLE NONE;PROPLOCNUM PROPLOCNUM VISIBLE NONE;TYPE TYPE VISIBLE NONE;FMUPDORG FMUPDORG VISIBLE NONE;FMUPDAT FMUPDAT VISIBLE NONE;FMSRCORG FMSRCORG VISIBLE NONE;Shape_STAr Shape_STAr VISIBLE NONE;Shape_STLe Shape_STLe VISIBLE NONE;Shape Shape VISIBLE NONE;Shape_ST_1 Shape_ST_1 HIDDEN NONE;Shape_ST_2 Shape_ST_2 HIDDEN NONE")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Layer To KML&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Converting town to KML")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.LayerToKML_conversion(parcelsProject_Layer, parcels, "0", "false", parcelsProject_Layer, "1024", "96", "CLAMPED_TO_GROUND")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--Any suggestions?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2016 20:11:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81148#M2820</guid>
      <dc:creator>BobBistrais</dc:creator>
      <dc:date>2016-01-07T20:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble deleting feature layer</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81149#M2821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bob,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of deleting the FeatureLayer, try overwriting it by adding the following line at the beginning of your script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14521980394223609 jive_text_macro" data-renderedposition="92_8_912_16" jivemacro_uid="_14521980394223609"&gt;&lt;P&gt;arcpy.env.overwriteOutput = 1&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/classes/env.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/classes/env.htm"&gt;env—ArcPy Classes | ArcGIS for Desktop&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2016 20:20:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81149#M2821</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2016-01-07T20:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble deleting feature layer</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81150#M2822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jake, and thanks for the reply.&amp;nbsp; I added the overwriteOutput line to my script, and I removed the delete featurelayer code.&amp;nbsp; Also added more Print lines so I can see what's going on.&amp;nbsp; The script is still quitting randomly.&amp;nbsp; In some attempts, it stopped while creating a new output directory for a KML, in other cases it quit while creating a feature layer.&amp;nbsp; But again, it quits with a different record each time.&amp;nbsp; And I am not seeing any error messages.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2016 22:23:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81150#M2822</guid>
      <dc:creator>BobBistrais</dc:creator>
      <dc:date>2016-01-07T22:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble deleting feature layer</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81151#M2823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you post more of your code (in code tags) for context?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2016 22:57:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81151#M2823</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-01-07T22:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble deleting feature layer</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81152#M2824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sorry, I don't see how to put it in code tags, but here is the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rows = gp.SearchCursor(workspace + "\\parcels_ut_town_list.dbf")&lt;/P&gt;&lt;P&gt;for row in rows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; town = row.town&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create Output Directory&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; towndir = town.strip()&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create Output Directory&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Processing" + " " + town)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Processing" + " " + town&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Creating Directory For" + " " + town)&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "creating outfolder for "+town&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outfolder = gp.CreateFolder_management(workspace, towndir)&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; ##Sometimes quitting here&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; expression = "TOWN = " + "'" + town.strip() + "'"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; parcels = outfolder + "\\parcels"+towndir+".kmz"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Make Feature Layer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "making feature layer"&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;&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; ##-And sometimes quitting around the next line-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(parcelsProject_shp, parcelsProject_Layer, expression, "", "FID FID VISIBLE NONE;TOWN TOWN VISIBLE NONE;COUNTY COUNTY VISIBLE NONE;GEOCODE GEOCODE VISIBLE NONE;STATE_ID STATE_ID VISIBLE NONE;MAP_BK_LOT MAP_BK_LOT VISIBLE NONE;PARENT PARENT VISIBLE NONE;PROP_LOC PROP_LOC VISIBLE NONE;PROPLOCNUM PROPLOCNUM VISIBLE NONE;TYPE TYPE VISIBLE NONE;FMUPDORG FMUPDORG VISIBLE NONE;FMUPDAT FMUPDAT VISIBLE NONE;FMSRCORG FMSRCORG VISIBLE NONE;Shape_STAr Shape_STAr VISIBLE NONE;Shape_STLe Shape_STLe VISIBLE NONE;Shape Shape VISIBLE NONE;Shape_ST_1 Shape_ST_1 HIDDEN NONE;Shape_ST_2 Shape_ST_2 HIDDEN NONE")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Layer To KML&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Converting town to KML")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Converting town to KML"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.LayerToKML_conversion(parcelsProject_Layer, parcels, "0", "false", parcelsProject_Layer, "1024", "96", "CLAMPED_TO_GROUND")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Copy Metadata&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Copying parcels Metadata For" + " " + town)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Copying parcels Metadata For" + " " + town&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; shutil.copy(metat, outfolder + "\\" + "parcels.txt")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Done Processing parcels For" + " " + town)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Done Processing parcels For" + " " + town&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Create The Zipfile&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #gp.AddMessage(output + "\\Parcels_" + towndir)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; zpfile = zipfile.ZipFile(output + "\\Parcels_" + towndir + ".zip", 'w')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; zpfile.write(outfolder + "\\parcels"+towndir+".kmz", "Parcels_" + towndir + ".kmz", zipfile.ZIP_DEFLATED)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; zpfile.write(outfolder + "\\parcels.txt", "Parcels_" + towndir + ".txt", zipfile.ZIP_DEFLATED)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; zpfile.close()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Delete Uncompressed Files&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; shutil.rmtree(outfolder)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("All Done Processing" + " " + town)&lt;/P&gt;&lt;P&gt;del rows&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jan 2016 14:42:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81152#M2824</guid>
      <dc:creator>BobBistrais</dc:creator>
      <dc:date>2016-01-08T14:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble deleting feature layer</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81153#M2825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you provide the line where you specify the workspace?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On a side note, why does your code flipflop between 'arcpy' and 'gp'? Are they both pointing to arcpy? Have you tried this with the superior &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#/SearchCursor/018w00000011000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;data access module SearchCursor&lt;/A&gt;?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's how to post in code tags (it's a bit convoluted):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migration-blogpost/1070" target="_blank"&gt;Posting Code blocks in the new GeoNet&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rows = gp.SearchCursor(workspace + "\\parcels_ut_town_list.dbf")
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; town = row.town
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create Output Directory
&amp;nbsp;&amp;nbsp;&amp;nbsp; towndir = town.strip()&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create Output Directory
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Processing" + " " + town)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Processing" + " " + town
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Creating Directory For" + " " + town) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "creating outfolder for "+town&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; outfolder = gp.CreateFolder_management(workspace, towndir)&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; ##Sometimes quitting here
&amp;nbsp;&amp;nbsp;&amp;nbsp; expression = "TOWN = " + "'" + town.strip() + "'"
&amp;nbsp;&amp;nbsp;&amp;nbsp; parcels = outfolder + "\\parcels"+towndir+".kmz"
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Make Feature Layer
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "making feature layer"&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;&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; ##-And sometimes quitting around the next line-
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(parcelsProject_shp, parcelsProject_Layer, expression, "", "FID FID VISIBLE NONE;TOWN TOWN VISIBLE NONE;COUNTY COUNTY VISIBLE NONE;GEOCODE GEOCODE VISIBLE NONE;STATE_ID STATE_ID VISIBLE NONE;MAP_BK_LOT MAP_BK_LOT VISIBLE NONE;PARENT PARENT VISIBLE NONE;PROP_LOC PROP_LOC VISIBLE NONE;PROPLOCNUM PROPLOCNUM VISIBLE NONE;TYPE TYPE VISIBLE NONE;FMUPDORG FMUPDORG VISIBLE NONE;FMUPDAT FMUPDAT VISIBLE NONE;FMSRCORG FMSRCORG VISIBLE NONE;Shape_STAr Shape_STAr VISIBLE NONE;Shape_STLe Shape_STLe VISIBLE NONE;Shape Shape VISIBLE NONE;Shape_ST_1 Shape_ST_1 HIDDEN NONE;Shape_ST_2 Shape_ST_2 HIDDEN NONE")
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Layer To KML
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Converting town to KML")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Converting town to KML"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.LayerToKML_conversion(parcelsProject_Layer, parcels, "0", "false", parcelsProject_Layer, "1024", "96", "CLAMPED_TO_GROUND")
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Copy Metadata&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Copying parcels Metadata For" + " " + town)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Copying parcels Metadata For" + " " + town
&amp;nbsp;&amp;nbsp;&amp;nbsp; shutil.copy(metat, outfolder + "\\" + "parcels.txt")
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Done Processing parcels For" + " " + town)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Done Processing parcels For" + " " + town
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Create The Zipfile
&amp;nbsp;&amp;nbsp;&amp;nbsp; #gp.AddMessage(output + "\\Parcels_" + towndir)
&amp;nbsp;&amp;nbsp;&amp;nbsp; zpfile = zipfile.ZipFile(output + "\\Parcels_" + towndir + ".zip", 'w')
&amp;nbsp;&amp;nbsp;&amp;nbsp; zpfile.write(outfolder + "\\parcels"+towndir+".kmz", "Parcels_" + towndir + ".kmz", zipfile.ZIP_DEFLATED)
&amp;nbsp;&amp;nbsp;&amp;nbsp; zpfile.write(outfolder + "\\parcels.txt", "Parcels_" + towndir + ".txt", zipfile.ZIP_DEFLATED)
&amp;nbsp;&amp;nbsp;&amp;nbsp; zpfile.close()
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Delete Uncompressed Files
&amp;nbsp;&amp;nbsp;&amp;nbsp; shutil.rmtree(outfolder)
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("All Done Processing" + " " + town)
del rows&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:06:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81153#M2825</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-10T23:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble deleting feature layer</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81154#M2826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;a visual to code formatting as well &lt;A href="https://community.esri.com/migration-blogpost/55181"&gt;Code Formatting... the basics++&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 Jan 2016 06:32:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81154#M2826</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-01-10T06:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble deleting feature layer</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81155#M2827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The workspace was set in an earlier part of the code, which wasn't pasted here.&amp;nbsp; This is the line:&lt;/P&gt;&lt;P&gt;workspace = 'C:\workspace\parcelsut'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will also try the data access module search cursor.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jan 2016 15:13:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81155#M2827</guid>
      <dc:creator>BobBistrais</dc:creator>
      <dc:date>2016-01-11T15:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble deleting feature layer</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81156#M2828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you need this:&lt;/P&gt;&lt;P&gt;workspace = 'C:\workspace\parcelsut'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; to be in "raw" format&lt;/P&gt;&lt;P&gt;workspace = r'C:\workspace\parcelsut'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or&lt;/P&gt;&lt;P&gt;workspace = 'C:/workspace/parcelsut'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or&lt;/P&gt;&lt;P&gt;workspace = 'C:\\workspace\\parcelsut'&lt;/P&gt;&lt;P&gt;If that is indeed the issue and not a copy paste error&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jan 2016 15:18:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81156#M2828</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-01-11T15:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble deleting feature layer</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81157#M2829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've made modifications as suggested by everyone, but still having the same problem.&amp;nbsp; In particular, I made the following changes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using arcpy.OverwriteOutput = 1 as suggested by Jake&lt;/P&gt;&lt;P&gt;Changed the rows with gp.SearchCursor to the arcpy.da.SearchCursor as suggested by Darren&lt;/P&gt;&lt;P&gt;Changed the workspace variable to raw format: workspace = r'C:\workspace\parcelsut as suggested by Dan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tested the looping process by commenting out the conversion to KMZ.&amp;nbsp; The looping/iteration works fine.&amp;nbsp; So I uncommented the KML conversion again.&amp;nbsp; Once again, the program will stop either when creating the feature layer, or when converting the feature layer to KMZ.&amp;nbsp; It stops with a different town each time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the problem appears to be in the KMZ conversion.&amp;nbsp; Is there any way to further diagnose why this is happening?&amp;nbsp; Is there an alternate approach to converting to KMZ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jan 2016 19:31:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81157#M2829</guid>
      <dc:creator>BobBistrais</dc:creator>
      <dc:date>2016-01-11T19:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble deleting feature layer</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81158#M2830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What are the names of the towns that cause it to fail? In particular, are there any special characters, like an apostrophe? Or, is it a different town each time?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jan 2016 19:38:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81158#M2830</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-01-11T19:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble deleting feature layer</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81159#M2831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My coding preference is to NOT use try, except blocks so that I can get a useable error message...others like them, but I prefer to be stopped cold in a line and fix it.&amp;nbsp; But...having said that, there are times that your logic seems to be deleting a layer that you are trying to use again in a makefeature layer?&amp;nbsp; I am not following something.&amp;nbsp; Could be a filename thing or a path thing, I would suggest printing full paths and change the names if necessary.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jan 2016 19:41:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81159#M2831</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-01-11T19:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble deleting feature layer</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81160#M2832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In this particular situation, we are not using the actual town names.&amp;nbsp; Instead the "town name" is actually an alphanumeric code as a text item.&amp;nbsp; Examples are AR021, HA007, PI063.&amp;nbsp; There are no special characters or spaces in any of the names.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And it is a different town each time- a town that will cause the program to quit on one try will work just fine on another try (and vice versa).&amp;nbsp; Again, no error messages, just stopping.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jan 2016 20:08:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81160#M2832</guid>
      <dc:creator>BobBistrais</dc:creator>
      <dc:date>2016-01-11T20:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble deleting feature layer</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81161#M2833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In an earlier version of the script I used Try blocks, but I have removed them in the current version (unless you see any that I didn't remove?).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll investigate the file/path names, but if you see anything in particular that looks suspicious, please let me know.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jan 2016 20:10:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/trouble-deleting-feature-layer/m-p/81161#M2833</guid>
      <dc:creator>BobBistrais</dc:creator>
      <dc:date>2016-01-11T20:10:22Z</dc:date>
    </item>
  </channel>
</rss>

