Skip To Content

Summarize Raster Within

Summary

Summarizes a raster based on areas (zones) defined by the first input layer.

Illustration

Summarize Raster Within tool

Usage

  • A zone is defined as all areas in the input that have the same value. The areas do not have to be contiguous.

  • When the zone and raster layer to summarize are both rasters of the same resolution, they will be used directly. If the resolutions are different, a resampling is applied to make them match before the zonal operation is performed.

  • The input raster layer to summarize can be either integer or floating point. However, when it is floating-point type, the zonal calculations for majority, median, minority, and variety will not be computed. For majority and minority calculations, when there is a tie, the output for the zone is based on the lowest of the tied values.

  • If the zone input is an image service, it must have an attribute table.

  • It is recommended to only use image services as the zone input, as it offers you greater control over the vector-to-raster conversion. This will help ensure you consistently get the expected results.

  • If the input zone is a feature service with relatively small features, the resolution needs to be relative to the resolution of the input raster layer to summarize. If the areas of single features are smaller than the area of single cells in the input raster layer to summarize, the feature-to-raster conversion of these zones will not be represented.

    If you have fewer results in the output than you expect, you need to determine an appropriate raster resolution that will represent the detail of your feature input and use this resolution as the Cell Size of the Raster Analysis Settings of the Environment.

  • If the zone input is a feature service, a vector-to-raster conversion will be applied internally. To ensure the results of the conversion will align properly with the input raster being summarized, it is recommended that you check to ensure the extent and snap raster are set appropriately in the environment settings and the raster settings.

  • If the zone input is a point feature dataset, it is possible to have more than one point contained within any particular cell of the input raster layer to summarize. For such cells, the zone value is determined by the point with the highest feature ID.

  • If the zone feature input 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 only have one value.

Syntax

SummarizeRasterWithin_ra (inputZoneLayer, zoneField, inputRasterLayertoSummarize, outputName, statisticType, {ignoreMissingValues})
ParameterExplanationData Type
inputZoneLayer

The layer that defines the boundaries of the areas. Both raster and feature services can be used for the zone input.

You specify a field to define the boundaries of the zones.

Raster Layer; Image Service; Feature Layer; String
zoneField

The field that defines each zone.

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

String
inputRasterLayertoSummarize

Choose the raster layer you want to summarize.

Raster Layer; Image Service; String
outputName

The name of the output raster service.

The default name is based on the tool name and the input layer name. If the layer already exists, you will be prompted to provide another name.

String
statisticType

Choose the statistic to calculate.

The available options when the summarize raster is integer are Average, Majority, Maximum, Median, Minimum, Minority, Range, Standard deviation, Sum, and Variety.

If the summarize raster is float, the options are Average, Maximum, Minimum, Range, Standard deviation, and Sum.

  • MEAN Calculates the average of all cells in the raster layer to be summarized that belong to the same zone as the output cell. This is the default.
  • MAJORITY Determines the 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.
  • MAXIMUM Determines the largest value of all cells in the raster layer to be summarized that belong to the same zone as the output cell.
  • MEDIAN Determines the median value of all cells in the raster layer to be summarized that belong to the same zone as the output cell.
  • MINIMUM Determines the smallest value of all cells in the raster layer to be summarized that belong to the same zone as the output cell.
  • MINORITY Determines the 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.
  • RANGE Calculates the 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.
  • STD Calculates the standard deviation of all cells in the raster layer to be summarized that belong to the same zone as the output cell.
  • SUM Calculates the total value of all cells in the raster layer to be summarized that belong to the same zone as the output cell.
  • VARIETY Calculates the number of unique values for all cells in the raster layer to be summarized that belong to the same zone as the output cell.
String
ignoreMissingValues
(Optional)

Specify whether missing values in the raster layer to summarize will influence the results of the areas they fall within.

  • DATAWithin any particular area, only cells that have a value in the raster layer being summarized will be used in determining the output value for that area. Any missing or NoData cells will be ignored in the statistic calculation. This is the default.
  • NODATAWithin any particular area, if any cells in the raster layer being summarized do not have a value, it is deemed that there is insufficient information to perform statistical calculations for all the cells in that zone; therefore, the entire zone will receive the NoData value on the output raster.
Boolean

Derived Output

NameExplanationData Type
outputRaster

The output raster.

Raster Layer

Code sample

SummarizeRasterWithin example 1 (Python window)

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

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

This example determines for each zone the mean value in the raster layer to be summarized.

#-------------------------------------------------------------------------------
# Name: SummarizeRasterWithin_Ex_02.py
# Description: Calculates statistics on values of a raster 
#              within the zones of another dataset.
# Requirements: ArcGIS Image Server

# Import system modules
import arcpy

# Set local variables
inputZoneLayer = 'https://MyPortal.esri.com/server/rest/services/Hosted/landuse/ImageServer'
zoneField = 'Landuse'
inputRasterLayertoSummarize = 'https://MyPortal.esri.com/server/rest/services/Hosted/elevation/ImageServer'
outputName = 'outRaster'
statisticType = 'MEAN' 
ignoreMissingValues = 'DATA' 

arcpy.SummarizeRasterWithin_ra(inputZoneLayer, zoneField, inputRasterLayertoSummarize,
                               outputName, statisticType, ignoreMissingValues)

Licensing information

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

Related topics