Batch processing Zonal Statistics As table

Discussion created by sventresca on Oct 9, 2012
Latest reply on Oct 12, 2012 by sventresca
I have been able to get a stand alone script to work and output a table for each of the rasters used in the ZonalStatisticsAsTable tool. However when I made it into a geoprocessing tool so that it would accept input from a user (as opposed to the hard-coded values that were in the stand alone script) it only outputs a single INFO table from the last raster that it processed. I have not been able to figure out how to make the script tool create an output table for each of the rasters. Any help is greatly appreciated!

import arcpy, os, sys, string
from arcpy import env
from import*

arcpy.env.overwriteOutput = True

# Get input parameters for the Zonal Statistics As Table tool
inPath = arcpy.GetParameterAsText(0)
zoneField = arcpy.GetParameterAsText(1)
rasterList = arcpy.GetParameterAsText(2).split(';')
outPath = arcpy.GetParameterAsText(3)

    for raster in rasterList:    

        ZonalStatisticsAsTable(inPath, zoneField, raster, outPath)         
        arcpy.AddField_management(outPath, "RasName", "TEXT")      
        arcpy.CalculateField_management(outPath, "RasName", '"'+os.path.splitext(os.path.basename(raster))[0]+'"')
    print arcpy.GetMessages(2)