As is not possible formulate, or add a solution to question:
Delete temporary files from geoprocessing in ArcGIS 10 and above , because is [closed]
I would like to make this question with same problem, I found that geoprocessing tools like arcpy.gp.SegmentMeanShift makes a lot of heavy temporal files (script is shown below) that keeps locked while the script shell still open, so you can't delete them, in the same Python script, also when tool is repeated in loop many times, script also crash.
I would like to ask for a correct way to manage this problem. I'm using Python 2.7, and ArcPy (ArcMap 10.6) package in Windows 10.
This is a part of script code that repeats many times "arcpy.gp.SegmentMeanShift_sa" on same raster (in this sample), so in this case on image shouldn't be the problem of crashing:
import arcpy import os # Check out any necessary licenses arcpy.CheckOutExtension("spatial") # segmentation variables Spectral_Detail = "15" Spatial_Detail = "18" Minimun_Segment = "9" # folders route work_folder = os.getcwd()+"\\work_folder" out = work_folder +"\\out" out_OS = work_folder +"\\out_OS" #geoprocessing order =0 while order < 150: order +=1 print "processing " +str(order) id_item = "31165796" arcpy.gp.SegmentMeanShift_sa(work_folder +"\\out\\"+id_item+".tif", out_OS+"\\" + id_item +"_"+Spectral_Detail+"_"+Spatial_Detail+"_"+Minimun_Segment+"_"+str(order)+".img", Spectral_Detail, Spatial_Detail, Minimun_Segment, "")
When this script is executed, these files are generated in temp directory each iteration (XX = random number):
SMS_Index_XX.til --> 32.768 kb
After more or less a hundred iterations, Python crash, whith this error:
Traceback (most recent call last):
File "D:/TALLER_SSD/20190405_SEGMENTACION/python/test/segmentacion_temporal_problem_2.py", line 212, in <module>
Spectral_Detail, Spatial_Detail, Minimun_Segment, "")
File "C:\Program Files (x86)\ArcGIS\Desktop10.6\ArcPy\arcpy\geoprocessing\_base.py", line 510, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
ExecuteError: ERROR 999998: Unexpected Error.
Failed to execute (SegmentMeanShift).
This crash is not the problem, errors can be controled, the problem still in main cuestion, temp files can't be deleted while script is running Python's Shell, filling disk space in many iterations. Even when script finish well and quit, temporary files are not deleted.
Any solution, or something missed?