I got a problem with Delete_management when I use the FeatureclassToCoverage_conversion function. I don't know why in the gdb I use (arcpy.env.scratchGDB), while the Delete_management is working, the folder is not completely deleted : 2 lockers file stay in.

Here is the code I use (I reduced it to the minimum) :

import os
import arcpy

from os.path import join

# User entries on ArcGIS
out_cover = "C:\Users\user\coverage"
in_lines = "C:\Users\user\lines.shp"
in_points = "C:\Users\user\points.shp"

# Unsplit the lines
fusionned_lines = join(arcpy.env.scratchGDB, "fusionned_lines")
arcpy.UnsplitLine_management(in_lines, fusionned_lines)

# Copy the feature
points = join(arcpy.env.scratchGDB, "points")
arcpy.CopyFeatures_management(in_points, points)

# List the feature classes to put in the coverage.
points_and_lines = [points, fusionned_lines]

# Create the coverage directory if needed.
if not arcpy.Exists(out_cover):

# Convert the feature class list into a coverage.
arcpy.FeatureclassToCoverage_conversion(points_and_lines, out_cover)

# The Delete_management of fusionned_lines and points is comparlsary, otherwise
# it is impossible to delete the scratch workspace.
# This delete does not work like I want :

In the scratch.gdb folder I always have a locker for fusionned_lines and a locker for points. For the first treatment it doesn't matter, but because of that I can't execute the script more than once.

Moreover, if I don't add the line : arcpy.FeatureclassToCoverage_conversion(points_and_lines, out_cover), the scratchGDB delete correctly. So the problem definitely come from here, but I don't know why or how.

  • 1
    Have you per chance set arcpy.env.scratchWorkspace = some gdb path? You need to undo your scratch workspace before you delete it. Try oldScratch = arcpy.env.scratchWorkspace ..do your stuff.. delGDB = arcpy.env.scratchGDB / arcpy.env.scratchWorkspace = oldScratch / arcpy.Delete_management(delGDB) - that should remove the whole lot. – Michael Stimson Apr 27 '15 at 22:01
  • No this is the whole code I let the scratch in the tmp files. – nytope Apr 28 '15 at 7:40
  • If you're not creating the scratch database then leave it alone. ArcGis needs a scratch database to operate.. of course remove your feature classes as you see fit but don't delete the scratch GDB. You should only delete a database that your process has created. – Michael Stimson Apr 28 '15 at 21:15
  • So I have to delete each feature class I create in the scratch GDB and I don't delete the scratch... But does it changes anything at the end of my script, to delete the scratchGDB ? – nytope Apr 29 '15 at 7:09
  • An other question : is it better to use this GDB for intermediate treatments or to create a TEMP GDB I could remove myself ? – nytope Apr 29 '15 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.