ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Cell Statistics

Available with Spatial Analyst license.

  • Summary
  • Illustration
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Calculates a per-cell statistic from multiple rasters.

The available statistics are Majority, Maximum, Mean, Median, Minimum, Minority, Range, Standard deviation, Sum, and Variety.

Learn more about how Cell Statistics works

Illustration

Cell Statistics - Sum illustration
OutRas = CellStatistics([InRas1, InRas2, InRas3], "SUM", "NODATA")

Usage

  • The order of the input rasters is irrelevant for this tool.

  • When a multiband raster is specified as one of the Input rasters or constant values (in_rasters_or_constants in Python), all the bands will be used.

    To process a selection of bands from a multiband raster, you can first create a new raster dataset composed of those particular bands with the Composite Bands tool, and use the result in the list of the Input rasters or constant values (in_rasters_or_constants in Python).

  • For statistic types Maximum, Minimum, Mean, Median, Majority, Minority and Sum, if a single raster is used as the input, the output cell values will be the same as the input cell values. For Range and STD the output cell values will all be 0, and for Variety, all 1.

  • See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.

Syntax

CellStatistics(in_rasters_or_constants, {statistics_type}, {ignore_nodata})
ParameterExplanationData Type
in_rasters_or_constants
[in_raster_or_constant,...]

A list of input rasters for which a statistic will be calculated for each cell within the Analysis window.

A number can be used as an input; however, the cell size and extent must first be set in the environment.

Raster Layer; Constant
statistics_type
(Optional)

Statistic type to be calculated.

  • MEAN —Calculates the mean (average) of the inputs.
  • MAJORITY —Determines the majority (value that occurs most often) of the inputs.
  • MAXIMUM —Determines the maximum (largest value) of the inputs.
  • MEDIAN —Calculates the median of the inputs.
  • MINIMUM —Determines the minimum (smallest value) of the inputs.
  • MINORITY —Determines the minority (value that occurs least often) of the inputs.
  • RANGE —Calculates the range (difference between largest and smallest value) of the inputs.
  • STD —Calculates the standard deviation of the inputs.
  • SUM —Calculates the sum (total of all values) of the inputs.
  • VARIETY —Calculates the variety (number of unique values) of the inputs.

The default statistic type is Mean.

String
ignore_nodata
(Optional)

Denotes whether NoData values are ignored by the statistic calculation.

  • DATA —At the processing cell location, if any of the input rasters has NoData, then that NoData value will be ignored. The statistics will be computed by only considering the cells with valid data. This is the default.
  • NODATA —If the processing cell location for any of the input rasters is NoData, then the output for that cell will be NoData.
Boolean

Return Value

NameExplanationData Type
out_raster

The output raster.

For each cell, the value is determined by applying the specified statistic type to the input rasters at that location.

Raster

Code sample

CellStatistics example 1 (Python window)

This example calculates the standard deviation per cell on several input Grid rasters and outputs the result as an IMG raster.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outCellStats = CellStatistics(["degs", "negs", "cost"], "STD", "DATA")
outCellStats.save("C:/sapyexamples/output/outcellstats.img")
CellStatistics example 2 (stand-alone script)

This example calculates the standard deviation per cell on several input Grid rasters and outputs the result as a Grid raster.

# Name: CellStatistics_Ex_02.py
# Description: Calculates a per-cell statistic from multiple rasters
# 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
inRaster01 = "degs"
inRaster02 = "negs"
inRaster03 = "cost"

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

# Execute CellStatistics
outCellStatistics = CellStatistics([inRaster01, inRaster02, inRaster03], "RANGE", "NODATA")

# Save the output 
outCellStatistics.save("C:/sapyexamples/output/cellstats")

Environments

  • Auto Commit
  • Cell Size
  • Cell Size Projection Method
  • Compression
  • Current Workspace
  • Extent
  • Geographic Transformations
  • Mask
  • Output CONFIG Keyword
  • Output Coordinate System
  • Scratch Workspace
  • Snap Raster
  • Tile Size

Licensing information

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

Related topics

  • An overview of the Local toolset

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal