adig22

Need help. Trying to  do a batch process with python (if possible)

Discussion created by adig22 on Sep 19, 2012
Greetings all,

I am trying to take a list of rasters from one workspace and put them in as inputs to a "BatchExtractByMask" process. I also have another list of polygons to clip by (spatially associated with each raster) that I want to put in as the Mask inputs. First off, is this possible at all? If it is, what am I doing wrong. I run the code below and get a "Problem encountered parse input list" on the line where the second masklist variable is declared (ConversionUtils).


import arcpy, sys, traceback, ConversionUtils

try:

    print "Initializing Program"

    
    #### Define Workspace and extensions

    # Spatial Analyst Extension

    arcpy.CheckOutExtension("Spatial")

    # Grids workspace

    arcpy.env.workspace = "J:\\USM\\WS722\\Members\\GrcicA\\Scan_Mosaic\\Mask_Polys"

    masklist = arcpy.ListFeatureClasses("*", "ALL")

    # The list is split by semi colons

    masklist = ConversionUtils.SplitMultiInputs(masklist)

    # Scans workspace

    arcpy.env.workspace = "J:\\USM\\WS722\\Members\\GrcicA\\Scan_Mosaic\\Scanned_images"

    rasterlist = arcpy.ListRasters("*", "ALL")

    # The list is split by semi colons

    rasterlist = ConversionUtils.SplitMultiInputs(rasterlist)

    

    

    # Define Variables

    outpath = "J:\\USM\WS722\\Members\\GrcicA\\Scan_Mosaic\\Final__Clipped_Images"

    # Delete Existing Data

    # Batch Clip

    print "Extracting"

    extractbymask = arcpy.BatchExtractByMask(rasterlist, masklist) 
    extractbymask.save(outpath)

    print "Program Complete"

except:

    
    tb = sys.exc_info()[2]
    tbinfo = traceback.format_tb(tb)[0]
    pymsg = "PYTHON ERRORS:\nTraceback Info:\n" + tbinfo + "\nError Info:\n     " +        str(sys.exc_type) + ": " + str(sys.exc_value) + "\n"
    msgs = "ARCPY ERRORS:\n" + arcpy.GetMessages(2) + "\n"

    arcpy.AddError(msgs)
    arcpy.AddError(pymsg)

    print msgs
    print pymsg
    
    arcpy.AddMessage(arcpy.GetMessages(1))
    print arcpy.GetMessages(1)



Any help would be much appreciated. I apologize if I posted this wrong, let me know if I can do anything to improve display of this message. Thanks!

-Adi

Outcomes