0

I have a large raster mosaic dataset that I would like to clip within several scripts simultaneously, but whenever I run two instances of a script simultaneously one always fails with the error:

arcgisscripting.ExecuteError: ERROR 999999: Something unexpected caused the tool to fail. Please refer to the error help for potential solutions, or contact Esri Technical Support http://esriurl.com/support. Failed to delete raster dataset Failed to execute (Clip)

Is there a way to allow multiple scripts to clip a mosaic raster dataset at the same time? Here is some example code:

import arcpy
import os
ras = arcpy.Raster(os.path.join('d.dbf', 'mosaic'))
pol = 'pol.shp'
result = arcpy.Clip_management(ras, '', 'result.tif', pol, '', 'ClippingGeometry')
  • 1
    This is more multi-processing than parallel-processing, but lock files and working directories are likely to trip up even multi-processing in the same workspace. – Vince Mar 2 at 20:50
  • I have encountered this issue even while working in separate workspaces. Do you believe lock files are the main issue here? – Forrest Williams Mar 2 at 21:31
  • 1
    There are also temporary processing areas which would need to be identified, but clipping from the same source is likely to be a nightmare. – Vince Mar 2 at 21:33
2

Heavy raster processing tasks are perfect candidates for multiprocessing.

Input:

enter image description here

Script:

import time, os
t0 = time.time()
import multiprocessing
from multiprocessing import Pool
import arcpy
mosaic=r'D:\Bulk_Data_Supply\Aerials_2010_2011\RURAL.gdb\TILES'
shpFile=r"C:\SCRATCH\fish_net.shp"

def clipMany(aList):
    shp, out_f=aList
    arcpy.Clip_management(mosaic, "", out_f,shp,"",'ClippingGeometry')
    return out_f
if __name__ == "__main__":
    aList=[row for row in arcpy.da.SearchCursor(shpFile,("Shape@","outRaster"))]
    p = Pool(3)
    print(p.map(clipMany, aList))
    print ('%i seconds' %(time.time()-t0))

Shapefile table:

enter image description here

Note: the source is the same mosaic dataset and outputs saved in the same folder

Output that took 46 seconds (most of it importing arcpy) to process on 2.8 Ghz processor, RAM 16, ArcGis 10.5:

enter image description here

Your Answer

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

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