Zonal Statistics As Table (Raster Analysis)

Summary

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

Illustration

Zonal Statistics As Table tool Illustration

Usage

  • This raster analysis portal tool is available when you are signed in to an ArcGIS Enterprise portal that has ArcGIS Image Server configured for Raster Analysis. When the tool is run, ArcGIS Pro serves as a client and the processing occurs in the servers federated with ArcGIS Enterprise. The portal tool accepts layers from your portal as input and creates output in your portal.

    The input raster layer supports a layer from the portal, a URI or URL to an image service, or the output from the Make Image Server Layer tool. The input feature layer can be a layer from the portal or a URI or URL to a feature service. This tool does not support local raster data or layers. While you can use local feature data and layers as input to this portal tool, best practice is to use layers from your portal as input.

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

  • If the Input Zone Raster or Features (inputZoneRasterOrFeatures in Python) is a raster, it must be an integer raster.

    If the zone is a feature, it will be converted to a raster internally using the cell size and cell alignment from the Input Value Raster (inputValueRaster in Python).

  • When the cell size of the Input Zone Raster or Features and the Input Value Raster are different, the output cell size will be the Maximum Of Inputs value, and the value raster image service will be used as the snap raster internally. If the cell size is the same but the cells are not aligned, the 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 Zone Raster or Features 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 necessary level of detail of the feature zones, and specify it in the analysis environment. Specifying a smaller cell size will generate a larger output raster. The higher resolution output will not necessarily be as high quality a result, since the additional detail does not exist in the Input Value Raster.

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

  • If the Input Zone Raster or Features is a point feature, more than one point may be contained within 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).

  • When specifying the Input Zone Raster or Features, 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 statistic type depends on the data type of the Input Value Raster, and the statistic calculation type specified by the Calculate Circular Statistics parameter.

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

    If the data type is float, arithmetic statistics calculation supports Mean, Maximum, Median, Minimum, Percentile, Range, Standard deviation, and Sum options; circular statistics calculation supports 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 (circularCalculation = "CIRCULAR" in Python), and specify a number for Circular Wrap Value (circularWrapValue in Python).

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

    The name of the field is the same as the Statistics type value 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.

Parameters

LabelExplanationData Type
Input Zone Raster or Features

The input that defines the zones.

Both raster and feature data can be used for the zone input.

Raster Layer; Feature Layer
Input Value Raster

The raster that contains the values on which to summarize a statistic.

Raster Layer
Output Table Name

The name of the output table.

If it's an existing table, you will be prompted to provide another name.

String
Zone Field

The field that defines each zone.

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

String
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
Statistic Type
(Optional)

Specifies the statistic type that will be calculated.

The available options when the value raster is integer are All, Mean, Majority, Majority count, Majority percentage, Majority value, count, and percentage, Maximum, Median, Minimum, Minority, Minority count, Minority percentage, Minority value, count, and percentage, Percentile, Range, Standard deviation, Sum, Variety, Minimum and Maximum, Mean and Standard deviation, and Minimum, Maximum and Mean.

If the value raster is float, the options are All, Mean, Maximum, Median, Percentile, Minimum, Range, Standard deviation, and Sum.

  • AllAll of the statistics will be calculated for an integer type value raster. All statistics except Median and Percentile will be calculated for a floating-point type value raster. This is the default.
  • MeanThe mean of all cells in the raster layer to be summarized that belong to the same zone as the output cell will be calculated.
  • MajorityThe value that occurs most often of all cells in the raster layer to be summarized 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 raster layer to be summarized that belong to the same zone as the output cell will be calculated.
  • MedianThe median value of all cells in the raster layer to be summarized that belong to the same zone as the output cell will be calculated.
  • MinimumThe smallest value of all cells in the raster layer to be summarized that belong to the same zone as the output cell will be calculated.
  • MinorityThe value that occurs least often of all cells in the raster layer to be summarized 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 raster layer to be summarized that belong to the same zone as the output cell will be calculated.
  • Standard deviationThe standard deviation of all cells in the raster layer to be summarized that belong to the same zone as the output cell will be calculated.
  • SumThe total value of all cells in the raster layer to be summarized that belong to the same zone as the output cell will be calculated.
  • VarietyThe number of unique values for all cells in the raster layer to be summarized 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 percentage The majority value, count, and percentage statistics will be calculated.
  • Minority value, count, and percentage The minority value, count, and percentage statistics will be calculated.
String
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 while calculating percentile.

Double
Process as Multidimensional
(Optional)

Specifies how the input rasters will be processed 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 (such as time or depth) from all slices of the multidimensional input rasters.
Boolean
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 used. This is the default.
  • NearestThe nearest available value to the desired percentile will be used.
  • LinearThe weighted average of the two surrounding values from the desired percentile will be used.
String
Calculate Circular Statistics
(Optional)

Specifies how the statistics type will be calculated.

  • Unchecked—Arithmetic statistics will be calculated. This is the default.
  • Checked—Circular statistics that are appropriate for cyclic quantities will be calculated, such as compass direction in degrees, daytimes, and fractional parts of real numbers.
Boolean
Circular Wrap Value
(Optional)

The highest possible value (upper bound) in the cyclic data. It is a positive number, with a default value of 360. This value also represents the same quantity as the lowest possible value (lower bound).

This parameter is only applicable when circular statistics are calculated.

Double

Derived Output

LabelExplanationData Type
Output Table

The output table.

Feature service without geometry

arcpy.ra.ZonalStatisticsAsTable(inputZoneRasterOrFeatures, inputValueRaster, outputTableName, zoneField, {ignoreNodata}, {statisticType}, {percentileValues}, {processAsMultidimensional}, {percentileInterpolationType}, {circularCalculation}, {circularWrapValue})
NameExplanationData Type
inputZoneRasterOrFeatures

The input that defines the zones.

Both raster and feature data can be used for the zone input.

Raster Layer; Feature Layer
inputValueRaster

The raster that contains the values on which to summarize a statistic.

Raster Layer
outputTableName

The name of the output table.

If it's an existing table, you will be prompted to provide another name.

String
zoneField

The field that defines each zone.

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

String
ignoreNodata
(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
statisticType
(Optional)

Specifies the statistic type that will be calculated.

The available options when the value raster is integer are ALL, MEAN, MAJORITY, MAJORITY_COUNT, MAJORITY_PERCENT, MAJORITY_VALUE_COUNT_PERCENT, MAXIMUM, MEDIAN, MINIMUM, MINORITY, MINORITY_COUNT, MINORITY_PERCENT, MINORITY_VALUE_COUNT_PERCENT, PERCENTILE, RANGE, STD, SUM, VARIETY, MINI_MAX, MEAN_SD, and MIN_MAX_MEAN.

If the value raster is float, the options are ALL, MEAN, MAXIMUM, MEDIAN, MINIMUM, PERCENTILE, RANGE, STD, and SUM.

  • ALLAll of the statistics will be calculated for an integer type value raster. All statistics except Median and Percentile will be calculated for a floating-point type value raster. This is the default.
  • MEANThe mean of all cells in the raster layer to be summarized that belong to the same zone as the output cell will be calculated.
  • MAJORITYThe value that occurs most often of all cells in the raster layer to be summarized 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 raster layer to be summarized that belong to the same zone as the output cell will be calculated.
  • MEDIANThe median value of all cells in the raster layer to be summarized that belong to the same zone as the output cell will be calculated.
  • MINIMUMThe smallest value of all cells in the raster layer to be summarized that belong to the same zone as the output cell will be calculated.
  • MINORITYThe value that occurs least often of all cells in the raster layer to be summarized 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_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 raster layer to be summarized that belong to the same zone as the output cell will be calculated.
  • STDThe standard deviation of all cells in the raster layer to be summarized that belong to the same zone as the output cell will be calculated.
  • SUMThe total value of all cells in the raster layer to be summarized that belong to the same zone as the output cell will be calculated.
  • VARIETYThe number of unique values for all cells in the raster layer to be summarized 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_PERCENT The majority value, count, and percentage statistics will be calculated.
  • MINORITY_VALUE_COUNT_PERCENT The minority value, count, and percentage statistics will be calculated.
String
percentileValues
[percentileValues,...]
(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 while calculating percentile.

Double
processAsMultidimensional
(Optional)

Specifies how the input rasters will be processed 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
percentileInterpolationType
(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 will be used.
  • LINEARThe weighted average of the two surrounding values from the desired percentile will be used.
String
circularCalculation
(Optional)

Specifies how the statistics type will be calculated.

  • ARITHMETICArithmetic statistics will be calculated. This is the default.
  • CIRCULARCircular statistics that are appropriate for cyclic quantities will be calculated, such as compass direction in degrees, daytimes, and fractional parts of real numbers.
Boolean
circularWrapValue
(Optional)

The highest possible value (upper bound) in the cyclic data. It is a positive number, with a default value of 360. This value also represents the same quantity as the lowest possible value (lower bound).

This parameter is only applicable when circular statistics are calculated.

Double

Derived Output

NameExplanationData Type
outputTable

The output table.

Feature service without geometry

Code sample

ZonalStatisticsAsTable example 1 (Python window)

This example determines for each zone the mean of cell values in the raster layer to be summarized.

import arcpy
arcpy.ra.ZonalStatisticsAsTable('https://MyPortal.esri.com/server/rest/services/Hosted/landuse/ImageServer',
                           	'https://MyPortal.esri.com/server/rest/services/Hosted/elevation/ImageServer',
    				'outTable', 'Landuse', '', 'MEAN')
ZonalStatisticsAsTable example 2 (stand-alone script)

This example determines for each zone the statistics values in the raster layer to be summarized.

#-------------------------------------------------------------------------------
# Name: ZonalStatisticsAsTable_Ex_02.py
# Description: Calculates all statistics with defined percentile values  
#              for sea-surface temperature defined by ecological zones.
# Requirements: ArcGIS Image Server

# Import system modules
import arcpy

# Set local variables
inputZoneRasterOrFeatures = 'https://MyPortal.esri.com/server/rest/services/Hosted/zones/ImageServer'
inputValueRaster = 'https://MyPortal.esri.com/server/rest/services/Hosted/seaSurfaceTemperature/ImageServer'
outputTableName = 'outZSAT'
zoneField = 'temperature'
ignoreNodata = '' 
statisticType = 'PERCENTILE'
percentileValues = [25,75,90]
processAsMultidimensional = 'ALL_SLICES'
percentileInterpolationType = 'NEAREST'

# Execute Multidimensional Zonal Statistics as Table
arcpy.ra.ZonalStatisticsAsTable(inputZoneRasterOrFeatures, inputValueRaster, outputTableName, zoneField,
                                ignoreNodata, statisticType, percentileValues, processAsMultidimensional, 
                                percentileInterpolationType)

Licensing information

  • Basic: Requires ArcGIS Image Server
  • Standard: Requires ArcGIS Image Server
  • Advanced: Requires ArcGIS Image Server

Related topics