Zonal Statistics as Table (Image Analyst)

Summary

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

Learn more about how the zonal statistics tools work

Illustration

Zonal Statistics as Table illustration
ZonalStatisticsAsTable(ZoneRas, "Value", ValRas, OutTable, "DATA", "MIN_MAX_MEAN")

Usage

  • A zone is defined as all areas in the input that have the same value. The areas do not have to be contiguous. Both rasters and features can be used for the zone input.

  • If the Input Raster or Feature Zone Data (in_zone_data in Python) value is a raster, it must be an integer raster.

  • If the Input Raster or Feature Zone Data is a feature, it will be converted to a raster internally using the cell size and cell alignment from the Input Value raster (in_value_raster in Python) parameter.

  • When the cell size of the Input Raster or Feature Zone Data and the Input Value Raster is different, the output cell size will be the Maximum Of Inputs value, and the Input Value Raster will be used as the snap raster internally. If the cell size is the same but the cells are not aligned, the Input Value Raster will be used as the snap raster internally. Either of these cases will trigger an internal resampling before the zonal operation is performed.

    When the zone and value inputs are both rasters of the same cell size and the cells are aligned, they will be used directly in the tool and will not be resampled internally during tool processing.

  • If the Input Raster or Feature Zone Data is a feature, for any of the zone features that do not overlap any cell centers of the value raster, those zones will not be converted to the internal zone raster. As a result, those zones will not be represented in the output. You can manage this by determining an appropriate value for the cell size environment that will preserve the desired level of detail of the feature zones, and specify it in the analysis environment.

  • If the Input Raster or Feature Zone Data value is a point feature, more than one point may be contained in any particular cell of the value input raster. For such cells, the zone value is determined by the point with the lowest ObjectID field (for example, OID or FID).

  • If the Input Raster or Feature Zone Data has overlapping features, the zonal analysis will be performed for each individual feature.

  • When specifying the Input Raster or Feature Zone Data value, the default zone field will be the first available integer or text field. If no other valid fields exist, the ObjectID field (for example, OID or FID) will be the default.

  • The supported statistics type depends on the data type of the Input Value Raster value, and the statistics calculation type specified by the Calculate Circular Statistics parameter.

    If the data type is integer, the arithmetic statistics calculation supports the Mean, Majority, Majority count, Majority percentage, Maximum, Median, Minimum, Minority, Minority count, Minority percentage, Percentile, Range, Standard deviation, Sum, and Variety options. The circular statistics calculation supports the Mean, Majority, Minority, Standard deviation, and Variety options.

    If the data type is float, the arithmetic statistics calculation supports the Mean, Maximum, Median, Minimum, Percentile, Range, Standard deviation, and Sum options. The circular statistics calculation supports the Mean and Standard deviation options.

  • For majority and minority calculations, when there is a tie, the output will be the lowest of the tied values.

  • To calculate circular statistics, check the Calculate Circular Statistics parameter (circular_calculation = "CIRCULAR" in Python), and specify a value for the Circular Wrap Value (circular_wrap_value in Python) parameter.

  • Supported multidimensional raster dataset types include multidimensional raster layer, mosaic, image service, and Esri CRF.

  • A field or series of fields will be created in the output table depending on the Statistics Type parameter setting (statisticType in Python).

    The name of the field is the same as the Statistics type for arithmetic statistics calculation. This is the default.

    However, for circular statistics the name of the field will be prefaced with C_, followed by the specified statistic. For example, the field name will be Median for the arithmetic median statistic and C_Median for the circular median statistic.

  • The data type for each value of the items in the output table is dependent on the zonal calculation being performed. See How the zonal statistics tools work for the specific behavior of a statistic.

  • The number of rows in the output table is the number of zones.

  • By default, this tool will use multicore processors if available. The maximum number of cores that can be used is four.

    To use fewer cores, use the Parallel Processing Factor environment setting.

  • See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.

Parameters

LabelExplanationData Type
Input Raster or Feature Zone Data

The dataset that defines the zones.

The zones can be defined by an integer raster or a feature layer.

Raster Layer; Feature Layer
Zone Field

The field that contains the values that define each zone.

It can be an integer or a string field of the zone dataset.

Field
Input Value Raster

The raster that contains the values for which a statistic will be calculated.

Raster Layer
Output Table

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

The format of the table is determined by the output location and path. By default, the output will be a geodatabase table if in a geodatabase workspace, and a dBASE table if in a file workspace.

Table
Ignore NoData in Calculations
(Optional)

Specifies whether NoData values in the value input will be ignored in the results of the zone that they fall within.

  • Checked—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. This is the default.
  • Unchecked—Within any particular zone, if NoData cells exist in the value raster, they will not be ignored and their existence indicates that there is insufficient information to perform statistical calculations for all the cells in that zone. Consequently, the entire zone will receive the NoData value on the output raster.
Boolean
Statistics Type
(Optional)

Specifies the statistic type to be calculated.

  • AllAll of the statistics will be calculated. This is the default.
  • MeanThe average of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • MajorityThe value that occurs most often for all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • Majority countThe frequency of all cells that contain the majority value in the value raster that belong to the same zone as the output cell will be calculated.
  • Majority percentageThe percentage of cells that contain the majority value in the value raster that belong to the same zone as the output cell will be calculated.
  • MaximumThe largest value of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • MedianThe median value of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • MinimumThe smallest value of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • MinorityThe value that occurs least often for all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • Minority countThe frequency of all cells that contain the minority value in the value raster that belong to the same zone as the output cell will be calculated.
  • Minority percentageThe percentage of cells that contain the minority value in the value raster that belong to the same zone as the output cell will be calculated.
  • PercentileThe percentile of all cells in the value raster that belong to the same zone as the output cell will be calculated. The 90th percentile is calculated by default. You can specify other values (from 0 to 100) using the Percentile values parameter.
  • RangeThe difference between the largest and smallest value of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • Standard deviationThe standard deviation of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • SumThe total value of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • VarietyThe number of unique values for all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • Minimum and MaximumBoth the minimum and maximum statistics will be calculated.
  • Mean and Standard deviationBoth the mean and standard deviation statistics will be calculated.
  • Minimum, Maximum, and MeanThe minimum, maximum, and mean statistics will be calculated.
  • Majority value, count, and percentageThe majority value, count, and percentage statistics will be calculated.
  • Minority value, count, and percentageThe minority value, count, and percentage statistics will be calculated.
String
Process as Multidimensional
(Optional)

Specifies how the input rasters will be calculated if they are multidimensional.

  • Unchecked—Statistics will be calculated from the current slice of the input multidimensional dataset. This is the default.
  • Checked—Statistics will be calculated for all dimensions of the input multidimensional dataset.
Boolean
Percentile Values
(Optional)

The percentile that will be calculated. The default is 90, indicating the 90th percentile.

The values can range from 0 to 100. The 0th percentile is essentially equivalent to the minimum statistic, and the 100th percentile is equivalent to maximum. A value of 50 will produce essentially the same result as the median statistic.

This parameter is only available if the Statistics type parameter is set to Percentile or All.

Double
Percentile Interpolation Type
(Optional)

Specifies the method of interpolation that will be used when the percentile value falls between two cell values from the input value raster.

  • Auto-detectIf the input value raster is of integer pixel type, the Nearest method will be used. If the input value raster is of floating point pixel type, the Linear method will be used. This is the default.
  • NearestThe nearest available value to the desired percentile is used.
  • LinearThe weighted average of the two surrounding values from the desired percentile is used.
String
Calculate Circular Statistics
(Optional)

Specifies how the input raster will be processed for circular data.

  • Unchecked—Ordinary linear statistics will be calculated. This is the default.
  • Checked—The statistics for angles or other cyclic quantities, such as compass direction in degrees, daytimes, and fractional parts of real numbers, will be calculated.
Boolean
Circular Wrap Value
(Optional)

The value that will be used to round a linear value to the range of a given circular statistic. Its value must be a positive integer or a floating-point value. The default value is 360 degrees.

This parameter is only supported if the Calculate Circular Statistics parameter is checked.

Double
Output Join Layer
(Optional)

The output layer that will be created by joining the output table to the input zone data.

Raster Layer; Feature Layer

ZonalStatisticsAsTable(in_zone_data, zone_field, in_value_raster, out_table, {ignore_nodata}, {statistics_type}, {process_as_multidimensional}, {percentile_values}, {percentile_interpolation_type}, {circular_calculation}, {circular_wrap_value}, {out_join_layer})
NameExplanationData Type
in_zone_data

The dataset that defines the zones.

The zones can be defined by an integer raster or a feature layer.

Raster Layer; Feature Layer
zone_field

The field that contains the values that define each zone.

It can be an integer or a string field of the zone dataset.

Field
in_value_raster

The raster that contains the values for which a statistic will be calculated.

Raster Layer
out_table

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

The format of the table is determined by the output location and path. By default, the output will be a geodatabase table if in a geodatabase workspace, and a dBASE table if in a file workspace.

Table
ignore_nodata
(Optional)

Specifies whether NoData values in the value input will be ignored in the results of the zone that they fall within.

  • DATAWithin 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. This is the default.
  • NODATAWithin any particular zone, if NoData cells exist in the value raster, they will not be ignored and their existence indicates that there is insufficient information to perform statistical calculations for all the cells in that zone. Consequently, the entire zone will receive the NoData value on the output raster.
Boolean
statistics_type
(Optional)

Specifies the statistic type to be calculated.

  • ALLAll of the statistics will be calculated. This is the default.
  • MEANThe average of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • MAJORITYThe value that occurs most often for all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • MAJORITY_COUNTThe frequency of all cells that contain the majority value in the value raster that belong to the same zone as the output cell will be calculated.
  • MAJORITY_PERCENTThe percentage of cells that contain the majority value in the value raster that belong to the same zone as the output cell will be calculated.
  • MAXIMUMThe largest value of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • MEDIANThe median value of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • MINIMUMThe smallest value of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • MINORITYThe value that occurs least often for all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • MINORITY_COUNTThe frequency of all cells that contain the minority value in the value raster that belong to the same zone as the output cell will be calculated.
  • MAJORITY_PERCENTThe percentage of cells that contain the minority value in the value raster that belong to the same zone as the output cell will be calculated.
  • PERCENTILEThe percentile of all cells in the value raster that belong to the same zone as the output cell will be calculated. The 90th percentile is calculated by default. You can specify other values (from 0 to 100) using the percentile_values parameter.
  • RANGEThe difference between the largest and smallest value of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • STDThe standard deviation of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • SUMThe total value of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • VARIETYThe number of unique values for all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • MIN_MAXBoth the minimum and maximum statistics will be calculated.
  • MEAN_STDBoth the mean and standard deviation statistics will be calculated.
  • MIN_MAX_MEANThe minimum, maximum, and mean statistics will be calculated.
  • MAJORITY_VALUE_COUNT_PERCENTThe majority value, count, and percentage statistics will be calculated.
  • MINORITY_VALUE_COUNT_PERCENTThe minority value, count, and percentage statistics will be calculated.
String
process_as_multidimensional
(Optional)

Specifies how the input rasters will be calculated if they are multidimensional.

  • CURRENT_SLICEStatistics will be calculated from the current slice of the input multidimensional dataset. This is the default.
  • ALL_SLICESStatistics will be calculated for all dimensions of the input multidimensional dataset.
Boolean
percentile_values
[percentile_values,...]
(Optional)

The percentile that will be calculated. The default is 90, indicating the 90th percentile.

The values can range from 0 to 100. The 0th percentile is essentially equivalent to the minimum statistic, and the 100th percentile is equivalent to maximum. A value of 50 will produce essentially the same result as the median statistic.

This parameter is only supported if the statistics_type parameter is set to PERCENTILE or ALL.

Double
percentile_interpolation_type
(Optional)

Specifies the method of interpolation that will be used when the percentile value falls between two cell values from the input value raster.

  • AUTO_DETECTIf the input value raster is of integer pixel type, the NEAREST method will be used. If the input value raster is of floating point pixel type, the LINEAR method will be used. This is the default.
  • NEARESTThe nearest available value to the desired percentile is used.
  • LINEARThe weighted average of the two surrounding values from the desired percentile is used.
String
circular_calculation
(Optional)

Specifies how the input raster will be processed for circular data.

  • ARITHMETICOrdinary linear statistics will be calculated. This is the default.
  • CIRCULARThe statistics for angles or other cyclic quantities, such as compass direction in degrees, daytimes, and fractional parts of real numbers, will be calculated.
Boolean
circular_wrap_value
(Optional)

The value that will be used to round a linear value to the range of a given circular statistic. Its value must be a positive integer or a floating-point value. The default value is 360 degrees.

This parameter is only supported if the circular_calculation parameter is set to CIRCULAR.

Double
out_join_layer
(Optional)

The output layer that will be created by joining the output table to the input zone data.

Raster Layer; Feature Layer

Code sample

ZonalStatisticsAsTable example 1 (Python window)

This example summarizes the values of a raster within the zones defined by a polygon shapefile and records the results in a table.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outZSaT = ZonalStatisticsAsTable("zones.shp", "Classes", "valueforzone",
                                  "zonalstattblout", "NODATA", "SUM")
ZonalStatisticsAsTable example 2 (stand-alone script)

This example summarizes the values of a raster within the zones defined by a polygon shapefile and records the results in a table.

# Name: ZonalStatisticsAsTable_Ex_02.py
# Description: Summarizes values of a raster within the zones of 
#              another dataset and reports the results to a table.
# Requirements: Spatial Analyst Extension

# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# Set environment settings
env.workspace = "C:/sapyexamples/data"

# Set local variables
inZoneData = "zones.shp"
zoneField = "Classes"
inValueRaster = "valueforzone"
outTable = "zonalstattblout02.dbf"


# Execute ZonalStatisticsAsTable
outZSaT = ZonalStatisticsAsTable(inZoneData, zoneField, inValueRaster, 
                                 outTable, "NODATA", "MEAN")

Related topics