Show Navigation | Hide Navigation
You are here:
Extensions > Spatial Analyst > Spatial Analyst functional reference > Zonal (Spatial Analyst)

Zonal Statistics as Table

Release 9.3
Last modified September 7, 2011
E-mail This Topic Printable Version Give Us Feedback

Print all topics in : "Zonal (Spatial Analyst)"


Related Topics

Summarizes the values of a raster within the zones of another dataset and reports the results to a table.

Learn more about how Zonal Statistics works


Illustration


Zonal Statistics As Table illustration

Command Line:
ZonalStatisticsAsTable ZoneRas VALUE ValRas OutTable

Usage tips

Command line syntax
An overview of the Command Line window
ZonalStatisticsAsTable_sa <in_zone_data> <zone_field> <in_value_raster> <out_table> {DATA | NODATA}

Parameter Explanation Data Type
<in_zone_data>

Dataset that defines the zones.

It can be a raster or feature dataset.

Composite Geodataset
<zone_field>

Field that holds the values that define each zone.

Field
<in_value_raster>

Raster that contains the values for which to calculate a statistic.

Composite Geodataset
<out_table>

Output table that will contain the summary of the values in each zone.

Table
{DATA | NODATA}

Denotes whether NoData values on the Value input will influence the results of the zone that they fall within.

  • DATA  — Within any particular zone, only cells that have a value in the input Value raster will be used in determining the output value for that zone. NoData cells in the Value raster will be ignored in the statistic calculation.
  • NODATA  — Within any particular zone, if any NoData cells exist in the Value raster it is deemed that there is insufficient information to perform statistical calculations for all the cells in that zone. Therefore, the entire zone will receive the NoData value on the output raster.

Boolean
Data types for geoprocessing tool parameters


Command line example

ZonalStatisticsAsTable_sa c:/data/ras_1 Value c:/data/ras_2 c:/data/final_1.dbf DATA

Scripting syntax
About getting started with writing geoprocessing scripts
ZonalStatisticsAsTable_sa (in_zone_data, zone_field, in_value_raster, out_table, ignore_nodata)

Parameter Explanation Data Type
in_zone_data (Required)

Dataset that defines the zones.

It can be a raster or feature dataset.

Composite Geodataset
zone_field (Required)

Field that holds the values that define each zone.

Field
in_value_raster (Required)

Raster that contains the values for which to calculate a statistic.

Composite Geodataset
out_table (Required)

Output table that will contain the summary of the values in each zone.

Table
ignore_nodata (Optional)

Denotes whether NoData values on the Value input will influence the results of the zone that they fall within.

  • DATA  — Within any particular zone, only cells that have a value in the input Value raster will be used in determining the output value for that zone. NoData cells in the Value raster will be ignored in the statistic calculation.
  • NODATA  — Within any particular zone, if any NoData cells exist in the Value raster it is deemed that there is insufficient information to perform statistical calculations for all the cells in that zone. Therefore, the entire zone will receive the NoData value on the output raster.

Boolean

Data types for geoprocessing tool parameters


Script example

# ZonalStatisticsAsTable.py
# Description: 
#   Summarizes values of a raster within the zones of another 
#   dataset and reports the results to a table.# Requirements: None
# Author: ESRI
# Date: Sept 6, 2005
# Import system modules
import arcgisscripting

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

try:
    # Set the input files
    inRaster1 = "c:/data/ras_1"
    inRaster2 = "c:/data/ras_2"

    # Set the output table name
    outTable = "c:/data/final_1.dbf"

    # Check out Spatial Analyst extension license
    gp.CheckOutExtension("Spatial")

    # Process: Zonal Statistics as Table
    cellSize = 1

    gp.ZonalStatisticsAsTable_sa(inRaster1, "Value", inRaster2, outTable, "DATA")

except:
    # If an error occurred while running a tool, then print the messages
    print gp.GetMessages()

Map Algebra syntax
See ZonalStats

ArcObjects syntax
IZonalOp::ZonalStatisticsAsTable (zone As IGeoDataset, value As IGeoDataset, ignoreNoData As Boolean) As ITable

Parameter Explanation
zone An input Raster, RasterDataset, RasterBand, or RasterDescriptor that identifies the zone for each value cell location.
value An input integer or floating-point Raster, RasterDataset, RasterBand, or RasterDescriptor defining the values of the cells to be used in the zonal calculations.
ignoreNoData A Boolean defining the manner in which NoData values on the valueDataset that fall within a zone defined by the zoneDataset will influence the output results.
If True, and if a NoData value exists in a cell on the value raster within any particular zone defined by zoneDataset, the cell will be ignored, and only cells on the value raster that have data values within the zone will be used in the processing for the output.
If False, and if a NoData value exists on the value raster within any particular zone defined by zoneDataset, there is insufficient information to complete the computation of the values for all the cells within the zone, and the entire zone will receive the NoData value on the output raster and will not appear in the output table.

ArcObjects example

' Create the RasterZonalOp object
Dim pZonalOp As IZonalOp
Set pZonalOp = New RasterZonalOp

' Declare the input zone raster object
Dim pZoneRaster As IGeoDataset

' Calls function to open a raster dataset from disk
Set pZoneRaster = OpenRasterDataset _
                    ("D:\SpatialData", "zoneraster")

' Declare the input value raster object
Dim pValueRaster As IGeoDataset

' Calls function to open a raster dataset from disk
Set pValueRaster = OpenRasterDataset _
                     ("D:\SpatialData", "valueraster")

' Declare the output table object
Dim pOutputTable As ITable

' Calls the method
Set pOutputTable = pZonalOp.ZonalStatisticsAsTable _
                     (pZoneRaster, pValueRaster, True)

Please visit the Feedback page to comment or give suggestions on ArcGIS Desktop Help.
Copyright © Environmental Systems Research Institute, Inc.