Zonal Statistcs as Table Python Script

240
2
05-15-2011 12:04 PM
CatherineChampagne
New Contributor
Hello,

I am trying to create a script to process zonal statistics on geoTiff files. So far I have this:
# ---------------------------------------------------------------------------
# zonalStats.py
# Created on: Sun May 15 2011 02:02:30 PM
#   (generated by ArcGIS/ModelBuilder)
# ---------------------------------------------------------------------------

# Import system modules
import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()

# Check out any necessary licenses
gp.CheckOutExtension("spatial")

# Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx")


# Local variables...
ZonalSt_Cano1 = "C:/Temp/ZonalSt.dbf"
Canola_AllShapes = "C:/Temp/Canola_AllShapes"
null_CLASS_SMA14_mask = "C:/Temp/null_CLASS_SMA14_mask.tif"

# Process: Zonal Statistics...
gp.Extent = "MAXOF"
gp.cellSize = 1000
gp.ZonalStatisticsAsTable_sa(Canola_AllShapes, "CSD", null_CLASS_SMA14_mask, ZonalSt_Cano1, "MEAN", "DATA")

When I run, I receive an error "ERROR 000621: Input to parameter ignore_nodata not within domain." I am new to scripting, so I would appreciate some help in finding the source of this error. My zone data set is a shapefile (but I receive the same error using this polygon converted to a raster file).

Thank you,
cc
0 Kudos
2 Replies
curtvprice
MVP Esteemed Contributor
Hello,

gp.ZonalStatisticsAsTable_sa(Canola_AllShapes, "CSD", null_CLASS_SMA14_mask, ZonalSt_Cano1, "MEAN", "DATA")

When I run, I receive an error "ERROR 000621: Input to parameter ignore_nodata not within domain."


Your parameters are not correct. The "MEAN" parameter is not a valid argument -- the 9.3 version of this tool does not let you specify specific statistics to calculate. (the 10.0 has such an argument tacked on the end -- thanks developers!)

gp.ZonalStatisticsAsTable_sa(Canola_AllShapes, "CSD", null_CLASS_SMA14_mask, ZonalSt_Cano1, "DATA")
0 Kudos
CatherineChampagne
New Contributor
Thank you! The script now works perfectly.
0 Kudos