I want to include Zonal Statistics to Table to my tool. But if I do I get the following error:

Traceback (most recent call last):
  File "C:\Users\xyz\Desktop\test.py", line 16, in <module>
    outZSaT = ZonalStatisticsAsTable(inshape, "field_id", ndvi, outTable, "DATA", "MEAN")
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\Functions.py", line 5836, in ZonalStatisticsAsTable
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\Utils.py", line 47, in swapper
    result = wrapper(*args, **kwargs)
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\Functions.py", line 5828, in wrapper
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\geoprocessing\_base.py", line 498, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
ExecuteError: ERROR 010423: C:\Users\xyz\AppData\Local\Temp\arc5F5D\t_t646 does not have valid statistics as required by the operation.
Failed to execute (ZonalStatisticsAsTable).

Failed to execute (test).
Failed at Tue Nov 07 08:31:06 2017 (Elapsed Time: 0.00 seconds)

Here is the code:

import os
import os.path
import sys
import datetime
import arcpy
from arcpy import env
from arcpy.sa import *

inshape = arcpy.GetParameterAsText(0)
ndvi = arcpy.GetParameterAsText(1)
out_location = arcpy.GetParameterAsText(2)

outTable = out_location + "\\outtable"
outZSaT = ZonalStatisticsAsTable(inshape, "field_id", ndvi, outTable, "DATA", "MEAN")

inshape: Feature layer, ndvi: Raster layer and out_location: Folder

If I replace the arcpy.GetParameterAsText with the actual path to the files and location and run in the python window it works fine. So where that t_t646 comes from?


1 Answer 1


If you define your tool parameters as layers (feature and raster layers) the tool will not accept a path to a feature class or raster since they're not layers. Feature/raster layers and table views are in-memory representations of your data. Feature layers might be accepted for a parameter of type 'feature class', but the opposite is not true.

So, change the data type of your first 2 parameters: use Feature Class for in_shape and Raster Dataset for ndvi.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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