Zonal Histogram (Spatial Analyst)

Summary

Creates a table and a histogram graph that show the frequency distribution of cell values on the Value input for each unique Zone.

Illustration

Zonal Histogram illustration
Zonal Histogram for land use zones and classified slope values

Usage

Syntax

ZonalHistogram (in_zone_data, zone_field, in_value_raster, out_table, {out_graph})
ParameterExplanationData Type
in_zone_data

Dataset that defines the zones.

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

Raster Layer | Feature Layer
zone_field

Field that holds 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 values to create the histograms.

Raster Layer
out_table

The output table file.

The optional graph is created from the information in the table.

Table
out_graph
(Optional)

The name of the output graph for display.

The graph is temporary. To persist it, use the Save Graph tool.

Graph

Code Sample

ZonalHistogram example 1 (Python window)

This example creates a zonal histogram .dbf table.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"

outZonHisto = ZonalHistogram("zoneras", "zonfield", "valueras", "znhist_tbl.dbf")

ZonalHistogram example 2 (stand-alone script)

This example creates a zonal histogram .dbf table and a graph file.

# Name: ZonalHistogram_Ex_02.py
# Description: Creates a zonal histogram output table and
#              a graph showing the amount of value cells 
#              for each unique input zone. 
# Requirements: Spatial Analyst Extension
# Author: ESRI

# 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" 
outGraph = "zonehist_gra" 

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

# Execute ZonalHistogram
ZonalHistogram(inZoneData, zoneField, inValueRaster, outTable, outGraph)

Environments

Related Topics

Licensing Information

ArcView: Requires Spatial Analyst
ArcEditor: Requires Spatial Analyst
ArcInfo: Requires Spatial Analyst

6/29/2011