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
statistics_type)
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
statistics_type)
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?