Zonal Geometry (Spatial Analyst)

Available with Spatial Analyst license.

Summary

Calculates the specified geometry measure (area, perimeter, thickness, or the characteristics of ellipse) for each zone in a dataset.

Learn more about how Zonal Geometry works

Illustration

Zonal Geometry illustration
OutRas = ZonalGeometry(InRas1,"VALUE","AREA")

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 raster and feature can be used for the zone input.

  • The Output cell size parameter can be defined by a numeric value or obtained from an existing raster dataset. If the cell size hasn’t been explicitly specified as the parameter value, it is derived from the Cell Size environment if it has been specified. If the parameter cell size or the environment cell size have not been specified, the default output cell size is determined based on the type of input dataset as follows:

    • If the input dataset is a raster, the cell size of the dataset is used.
    • If the input dataset is a feature and the Snap Raster environment has been set, the cell size of the snap raster is used. If no snap raster is set, the cell size is calculated from the shorter of the width or height of the extent divided by 250 in which the extent is in the output coordinate system specified in the environment.
  • If the cell size is specified using a numeric value, the tool will use it directly for the output raster.

    If the cell size is specified using a raster dataset, the parameter will show the path of the raster dataset instead of the cell size value. The cell size of that raster dataset will be used directly in the analysis, provided the spatial reference of the dataset is the same as the output spatial reference. If the spatial reference of the dataset is different than the output spatial reference, it will be projected based on the selected Cell Size Projection Method value.

  • 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.

  • 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 data type of the output raster for each of the geometry types will be floating point.

  • If a particular zone consists of only one cell or if the zone is a single square block of cells, the orientation of the ellipse (which, in this case, is a circle) is set to 90 degrees.

  • 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 must be an integer field of the zone dataset.

Field
Geometry type
(Optional)

Geometry type to be calculated.

  • AreaThe area for each zone.
  • PerimeterThe perimeter for each zone.
  • ThicknessThe deepest (or thickest) point within the zone from its surrounding cells.
  • CentroidLocates the centroids of each zone.
String
Output cell size
(Optional)

The cell size of the output raster that will be created.

This parameter can be defined by a numeric value or obtained from an existing raster dataset. If the cell size hasn't been explicitly specified as the parameter value, the environment cell size value will be used if specified; otherwise, additional rules will be used to calculate it from the other inputs. See the usage section for more detail.

Analysis Cell Size

Return Value

LabelExplanationData Type
Output raster

The output zonal geometry raster.

Raster

ZonalGeometry(in_zone_data, zone_field, {geometry_type}, {cell_size})
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 must be an integer field of the zone dataset.

Field
geometry_type
(Optional)

Geometry type to be calculated.

  • AREAThe area for each zone.
  • PERIMETERThe perimeter for each zone.
  • THICKNESSThe deepest (or thickest) point within the zone from its surrounding cells.
  • CENTROIDLocates the centroids of each zone.
String
cell_size
(Optional)

The cell size of the output raster that will be created.

This parameter can be defined by a numeric value or obtained from an existing raster dataset. If the cell size hasn't been explicitly specified as the parameter value, the environment cell size value will be used if specified; otherwise, additional rules will be used to calculate it from the other inputs. See the usage section for more detail.

Analysis Cell Size

Return Value

NameExplanationData Type
out_raster

The output zonal geometry raster.

Raster

Code sample

ZonalGeometry example 1 (Python window)

This example determines the area for each zone defined by the input polygon shape file.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outZonalGeometry = ZonalGeometry("zones.shp", "Classes", "AREA", 0.2)
outZonalGeometry.save("C:/sapyexamples/output/zonegeomout3")
ZonalGeometry example 2 (stand-alone script)

This example determines the area for each zone defined by the input polygon shape file.

# Name: ZonalGeometry_Ex_02.py
# Description:Calculates for each zone in a dataset the specified geometry 
#   measure (area, perimeter, thickness, or the characteristics 
#   of ellipse).
# 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"
cellSize = 0.2

# Execute ZonalStatistics
outZonalGeometry = ZonalGeometry(inZoneData, zoneField, "AREA", cellSize)  

# Save the output 
outZonalGeometry.save("C:/sapyexamples/output/zonegeomout2")

Licensing information

  • Basic: Requires Spatial Analyst
  • Standard: Requires Spatial Analyst
  • Advanced: Requires Spatial Analyst

Related topics