Label | Explanation | Data 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 used to create the histogram. | Raster Layer |
Output table | The output table file. 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. The optional graph output is created from the information in the table. | Table |
Output graph name (Optional) | The name of the output graph for display. The graph is listed in the Contents pane under Standalone Tables. | Graph |
Zones as rows in output table (Optional) | Specifies how the values from the input value raster will be represented in the output table.
| Boolean |
Summary
Creates a table and a histogram graph that show the frequency distribution of cell values on the value input for each unique zone.
Usage
A zonal histogram allows you to investigate the frequency distribution of values in one dataset within classes of another dataset. Examples include slope distribution within land use classes, rainfall distribution within elevation classes, or crime distribution by police beat.
The number of classes in a zonal histogram depends on how the Input value raster (in_value_raster in Python) is specified.
When specified as a raster dataset, the following conditions will apply:
- For an integer raster with less than 25 unique values, the number of classes will match the number of unique values from the value raster.
- For an integer raster with more than 25 unique values, the values will be divided into 256 classes, from 1 to 256. If the number of unique values is less than 256, some of the classes will have a frequency of 0.
- For a floating-point raster, the values will be divided into 256 classes, from 1 to 256.
When specified as raster layer, the following conditions will apply:
- For Stretch symbology, the stretch type will be used and the values will be divided into 256 classes, from 1 to 256.
- For Classify or Unique Values symbology, the number of classes will match the classes or the unique values from the symbology.
- The zonal analysis will be performed within the value range specified by the Stretch, Classify, or Unique Values symbology. Any values in the value raster that are not displayed in the symbology will be ignored from the calculation.
- For Discrete or Vector Field symbology, the zonal analysis will ignore the symbology. The analysis will be performed considering only the data type and the number of unique values in the value raster, in the same way as when the input value raster is specified as a raster dataset.
- The zonal histogram will show the class values from the value raster layer symbology labels.
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 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 value has overlapping polygons, the zonal analysis will not be performed for each individual polygon. Since the feature input is converted to a raster, each location can have only one value.
An alternative method is to process the zonal operation iteratively for each of the polygon zones and collate the results.
The Zone field parameter (zone_field in Python) value must be either integer or text type.
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.
A zonal histogram graph is not generated by default. To create the graph, check the Zones as rows in output table parameter (set the zones_as_rows parameter to ZONES_AS_ROWS in Python) and specify an Output graph name (out_graph parameter in Python). The zonal histogram graph can only be created within the ArcGIS AllSource application and is not supported from a stand-alone script.
When the output table is created by unchecking the Zones as rows in output table parameter, the label field will contain the values from the value raster dataset or the layer symbology labels, depending on how the input value raster is specified.
When the output table is created by checking the Zones as rows in output table parameter, the label field will contain the values from the zone raster.
See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.
Parameters
ZonalHistogram(in_zone_data, zone_field, in_value_raster, out_table, {out_graph}, {zones_as_rows})
Name | Explanation | Data 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 used to create the histogram. | Raster Layer |
out_table | The output table file. 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. The optional graph output is created from the information in the table. | Table |
out_graph (Optional) | The name of the output graph for display. | Graph |
zones_as_rows (Optional) | Specifies how the values from the input value raster will be represented in the output table.
| Boolean |
Code sample
This example creates a zonal histogram .dbf table and a graph file.
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outZonalHist = ZonalHistogram("zoneras", "zonfield", "valueras", "znhist_tbl.dbf",
"znhist_graphl", "ZONES_AS_ROWS")
This example creates a zonal histogram .dbf table.
# Name: ZonalHistogram_Ex_02.py
# Description: Creates a zonal histogram output table
# showing the amount of value cells
# for each unique input zone.
# 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 = "zonras"
zoneField = "zonfield"
inValueRaster = "valueras"
outTable = "C:/sapyexamples/output/zonehist_tbl.dbf"
# Execute ZonalHistogram
ZonalHistogram(inZoneData, zoneField, inValueRaster, outTable)