v3_Utility Select Zonal Statistics - USEPA/ATtILA2 GitHub Wiki

Select Zonal Statistics

Available with Spatial Analyst license.

Summary

Calculates select zonal statistics within reporting unit polygons and creates an output table.

Usage

  • This tool processes all polygons in the Reporting unit feature layer regardless of selections set. The ability to limit calculations to only selected reporting unit polygons is not supported in this release.

  • The list of selectable statistics is dependent on the Input value raster type.

    • For integer grids, supported statistics are: MIN, MAX, RANGE, MEAN, STD, SUM, VARIETY, MAJORITY, MAJORITY_COUNT, MAJORITY_PERCENT, MINORITY, MINORITY_COUNT, MINORITY_PERCENT, MEDIAN, PCT90.

    • For floating point grids, supported statistics are: MIN, MAX, RANGE, MEAN, MEDIAN, STD, SUM, PCT90.

  • Field names in the Output table follow this naming scheme:

    • Field_prefix_[selected statistic]

      • (e.g., SLOPE_MEAN for a Field_prefix of "SLOPE" and a selected statistic of "MEAN")

      • The string combination of Field_prefix and [selected statistic] must conform to the field naming conventions dictated by the output database system.

        • In general, try to restrict field names to just alphanumeric characters and underscores. Use of spaces and special characters should be avoided, as well as beginning a field name with a number or an underscore. For more guidelines on the naming of fields, search on "Fundamentals of adding and deleting fields" in the ArcGIS help documentation.

        • Field names in a geodatabase tables are restricted to 64 characters in length while field names in a dBase table are restricted to 10 characters in length.

  • An AREA_OVER field is automatically generated and added to the Output table for quality assurance purposes. It measures the percent overlap between the Reporting unit feature and the Input value raster for each reporting unit.

    • NOTE: The area of the Reporting unit feature vector polygon and the zonal area calculated from the Input value raster are rarely the same even when there is complete overlap between the two. Because of this, values slightly above or below 100 in the AREA_OVER field are to be expected. Values noticeably below 100 indicate a possible problem area where data from the Input value raster may not extend throughout the reporting unit feature.
  • In Additional Options, the user may elect to 'Record Process Steps Taken During Metric Calculation'.

    • Choosing LOGFILE - Record Process Steps Taken During Metric Calculation will generate a text file containing information on system setup, tool inputs, parameter selections, script operations, and any encountered error or warning messages.

    • Log files will be named, [Output table]_[date_time].txt, with the date represented as YYYYMMDD and time as hh_mm_ss.

    • Where the log file is saved is dependent on the Current Workspace environment setting:

      • When the Current Workspace is a geodatabase, the log file will be located in the folder that contains that workspace.

      • When the Current Workspace is a folder, the log file will be located in that folder.

      • NOTE: In ArcGIS Pro, the default value for the Current Workspace environments is the project default geodatabase.

      • NOTE: ATtILA will report the name and location of the log file in the Tool Details' Messages section.

Syntax

SZS (Reporting_unit_feature, Reporting_unit_ID_field, In_value_raster, Statistics_type, Output_table, Field_prefix, {Select_options})

Parameter Explanation Data Type
Reporting_unit_feature The vector polygon dataset that defines the reporting units. Feature Layer
Reporting_unit_ID_field The field in the Reporting unit feature layer that contains the unique ID for each reporting unit.

It may be an integer or a string data type.
Field
In_value_raster The raster that contains the values for which a statistic will be calculated.

Takes integer or floating point raster type.
Raster Layer
Statistics_type Specifies the statistic type to be calculated.

  • ALL—All of the statistics will be calculated. This is the default.
  • MIN—The smallest value of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • MAX—The largest value of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • RANGE—The 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.
  • MEAN—The average of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • STD—The standard deviation of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • SUM—The total value of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • VARIETY—The number of unique values for all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • MAJORITY—The 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_COUNT—The 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_PERCENT—The 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.
  • MINORITY—The 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_COUNT—The 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_PERCENT—The 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.
  • MEDIAN—The median value of all cells in the value raster that belong to the same zone as the output cell will be calculated.
  • PCT90—The 90th percentile of all cells in the value raster that belong to the same zone as the output cell will be calculated.
Multiple Value
Output_table The output reporting unit statistics table to be created.

It is recommended that the Output table be saved within a file geodatabase.
Table
Field_prefix A character string used as the field name prefix for all output statistics. String
Select_options Tool options available to provide additional information:

  • Record Process Steps Taken During Metric Calculation - Saves a log file containing information on tool inputs, selections, and operations.
Multiple Value

Code Samples

Select Zonal Statistics example 1 (Python window)

This example returns a table with a SLOPE raster's MAX, MEAN, and MEDIAN value for each WATERSHED reporting unit zone. The option to record the process steps into a log file has also been selected.

import arcpy
from arcpy.sa import *
arcpy.ImportToolbox(r**D:\Destination Folder\ATtILA v{#}.tbx**)

Reporting_unit_feature = **D:\\pyexamples\\data.gdb\\Watersheds**
Reporting_unit_ID_field = **HUC12**
Input_value_raster = **D:\\pyexamples\\data.gdb\\Slope**
Statistics_type = **MAX;MEAN;MEDIAN**
Output_table = **D:\\pyexamples\\results.gdb\\Watersheds_SZS**
Field_prefix = **SLOPE**
Select_options = **'LOGFILE  -  Record Process Steps Taken During Metric Calculation'** 

arcpy.ATtILA.SZS(
                 Reporting_unit_feature,
                 Reporting_unit_ID_field,
                 Input_value_raster,
                 Statistics_type,
                 Output_table,
                 Field_prefix,
                 Select_options
                 )
 

Credits

Use limitations

There are no access and use limitations for this item.


arrow_up Top of the page     |     arrow_left Process Roads for EnviroAtlas Analyses     |     arrow_right Land Cover Classification


⚠️ **GitHub.com Fallback** ⚠️