I have a simple script that gets all layers in a gdb and uses them to clip a DEM. What's happening though is it starts the clipping but never finishes and after killing the process I am unable to delete the file because of some lock on the file. Any thoughts/ideas on what's causing this or how to fix it? I tried the exact parameters within arcmap with no issues and zippy performance.

[EDIT Working code below]

for dirpath, dirnames, filenames in arcpy.da.Walk(clipLayers, datatype="FeatureClass", type="ALL"):
for filename in filenames:
    if "ENG_NAME" in [f.name for f in arcpy.ListFields(os.path.join(dirpath, filename))]:
        print "Clipping: ", filename
        arcpy.env.overwriteOutput = True
        arcpy.Clip_management(dem, "#", r"M:/Masks_Test.gdb/" + filename + "_Clip", os.path.join(dirpath, filename), "0", "ClippingGeometry")

1 Answer 1


Perhaps the DEM is in geographic coordinates. If there is projection-on-the-fly going on based on geoprocessing settings, those settings are not seen if running the python process standalone.

Note, you only need to set overwriteOutput once and it remains in effect, you can move it out the loop (though it's not a performance thing, just style!)

  • Thanks for the reply. All layers and DEM are in WGS84. Thanks for the tip on overwriteOutput!
    – cbrannin
    Jul 7, 2014 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.