Aggregate (Spatial Analyst)

License Level:BasicStandardAdvanced

Summary

Generates a reduced-resolution version of a raster. Each output cell contains the Sum, Minimum, Maximum, Mean, or Median of the input cells that are encompassed by the extent of that cell.

Learn more about how Aggregate works

Illustration

Aggregate illustration
OutRas = Aggregate(InRas1, 3, Max, Expand, Data)

Usage

Syntax

Aggregate (in_raster, cell_factor, {aggregation_type}, {extent_handling}, {ignore_nodata})
ParameterExplanationData Type
in_raster

The input raster to aggregate.

It can be of integer or floating point type.

Raster Layer
cell_factor

The factor by which to multiply the cell size of the input raster to obtain the desired resolution for the output raster.

For example, a cell factor value of three would result in an output cell size three times larger than that of the input raster.

The value must be an integer greater than 1.

Long
aggregation_type
(Optional)

Establishes how the value for each output cell will be determined.

The values of the input cells encompassed by the coarser output cell are aggregated by one of the following statistics:

  • SUMThe sum (total) of the input cell values. This is the default.
  • MAXIMUM The largest value of the input cells.
  • MEAN The average value of the input cells.
  • MEDIAN The median value of the input cells.
  • MINIMUM The smallest value of the input cells.
String
extent_handling
(Optional)

Defines how to handle the boundaries of the input raster when its rows or columns are not a multiple of the cell factor.

  • EXPAND Expands the bottom or right boundaries of the input raster so the total number of cells in a row or column is a multiple of the cell factor. Expanded cells are given a value of NoData.With this option, the output raster can cover a larger spatial extent than the input raster. This is the default. This is the default.
  • TRUNCATE Reduces the number of rows or columns in the output raster by 1. This will truncate the remaining cells on the bottom or right boundaries of the input raster, making the number of rows or columns in the input raster a multiple of the cell factor.With this option, the output raster can cover a smaller spatial extent than the input raster.

If the number of rows and columns in the input raster is a multiple of the cell_factor, these keywords are not used.

Boolean
ignore_nodata
(Optional)

Denotes whether NoData values are ignored by the aggregation calculation.

  • DATA Specifies that if NoData values exist for any of the cells that fall within the spatial extent of a larger cell on the output raster, the NoData values will be ignored when determining the value for output cell locations. Only input cells within the extent of the output cell that have data values will be used in determining the value of the output cell. This is the default.
  • NODATA Specifies that if any cell that falls within the spatial extent of a larger cell on the output raster has a value of NoData, the value for that output cell location will be NoData.When the NODATA keyword is used, it is implied that when cells within an aggregation contain the NoData value, there is insufficient information to perform the specified calculations necessary to determine an output value.
Boolean

Return Value

NameExplanationData Type
out_raster

The output aggregated raster.

It is a reduced-resolution version of the input raster.

Raster

Code Sample

Aggregate example 1 (Python window)

This example aggregates a raster by averaging the values with a cell factor of 3 and outputs a TIFF raster.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outAggreg = Aggregate("highres", 3, "MAXIMUM", "TRUNCATE", "DATA")
outAggreg.save("C:/sapyexamples/output/aggregate.tif")
Aggregate example 2 (stand-alone script)

This example aggregates a raster by averaging the values with a cell factor of 3 and outputs a GRID raster.

# Name: Aggregate_Ex_02.py
# Description: Generates a reduced resolution version of a raster.
# 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
inRaster = "highres"
cellFactor = 3

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

# Execute Aggregate
outAggreg = Aggregate(inRaster, cellFactor, "MEAN", "TRUNCATE", "NODATA")

# Save the output 
outAggreg.save("C:/sapyexamples/output/aggregate02")

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Requires Spatial Analyst
ArcGIS for Desktop Standard: Requires Spatial Analyst
ArcGIS for Desktop Advanced: Requires Spatial Analyst
11/8/2012