Skip to main content

Mean

Summary

Creates a raster object in which each pixel contains the average value across multiple rasters.

Discussion

The referenced raster dataset for the raster object is temporary. To make it permanent, you can call the raster object's save method.

Syntax

Mean(rasters, {extent_type}, {cellsize_type}, {ignore_nodata}, {process_as_multiband})

Parameter Explanation Data Type

rasters

The list of input rasters.

Raster

extent_type

The method that will be used to compute the extent of the output when the input rasters have different extents.

  • FirstOf—The output extent will be defined using the extent of the first input raster.

  • LastOf—The output extent will be defined using the extent of the last input raster.

  • IntersectionOf—The output extent will be defined as the intersecting area of the input rasters.

  • UnionOf—The output extent will be defined as the total extent of the input rasters.

The default value is FirstOf.

String

cellsize_type

The method that will be used to compute the pixel size of the output when the input rasters have different pixel sizes.

  • FirstOf—The output pixel size will be defined using the pixel size of the first input raster.

  • LastOf—The output pixel size will be defined using the pixel size of the last input raster.

  • MaxOf—The output pixel size will be defined using the maximum pixel size of the input rasters.

  • MeanOf—The output pixel size will be defined using the mean of both input rasters.

  • MinOf—The output pixel size will be defined using the minimum pixel size of the input rasters.

The default value is FirstOf.

String

ignore_nodata

Specifies whether NoData values will be ignored in the calculation.

  • True—The analysis will include all valid pixels in the input rasters and ignore any NoData pixels.

  • False—The analysis will result in NoData if there are any NoData values for the pixels in the input rasters.

The default value is False.

Boolean

process_as_multiband

Specifies how the bands of the input rasters will be processed.

  • True—Each multiband raster will be processed as a multiband raster. The operation will be performed for each band from one input using the corresponding band number from other inputs.

  • False—Each band from a multiband raster input will be processed separately as a single-band raster.

The default value is False.

Boolean

Return value

Data Type Explanation

Raster

The output raster.

Code sample

Mean example

Calculates the average value across three multiband rasters.

from arcpy.ia import *

rc = RasterCollection([landsat_1, landsat_2, landsat_3])

mean_raster = Mean(rc, extent_type = "UnionOf", cellsize_type = "MinOf",
        ignore_nodata = True, process_as_multiband = True)