I have been trying to calculate the mean value of each band in a multiband raster to a feature class as once using zonal statistics as table in arcpy environment. At present my multiband raster do have 36 bands, and i am successfully able to iterate over it but don't know why it is getting failed at Zonal statistics execution time. The code is attached below:
import arcpy
import os
from arcpy import env
from arcpy.sa import *
env.workspace = r'X:\600_POINT_DATA\Layerstack\layerstack_2017.img'
raslist = arcpy.ListRasters()
for ras in raslist:
out_table = os.path.join(env.workspace, ras + '_tab')
arcpy.gp.ZonalStatisticsAsTable_sa('Village_1', 'key', ras, out_table, 'NODATA', 'MEAN')
Error:
Traceback (most recent call last):
File "<string>", line 9, in <module>
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.
Failed to execute (ZonalStatisticsAsTable).