Calculate Statistics (Data Management)

Summary

Calculates statistics for a raster dataset or mosaic dataset.

Statistics are required for your raster and mosaic datasets to perform certain tasks, such as applying a contrast stretch or classifying your data.

Usage

Syntax

CalculateStatistics_management (in_raster_dataset, {x_skip_factor}, {y_skip_factor}, {ignore_values})
ParameterExplanationData Type
in_raster_dataset

The input raster dataset or mosaic dataset.

Mosaic Dataset; Mosaic Layer; Raster Dataset
x_skip_factor
(Optional)

The number of horizontal pixels between samples.

The value must be greater than zero and less than or equal to the number of columns in the raster dataset. The default is 1 or the last skip factor used.

The skip factors for raster datasets stored in a file geodatabase or an ArcSDE geodatabase are different. First, if the x and y skip factors are different, the smaller skip factor will be used for both the x and y skip factors. Second, the skip factor is related to the pyramid level that most closely fits the skip factor chosen. If the skip factor value is not equal to the number of pixels in a pyramid layer, the number is rounded down to the next pyramid level, and those statistics are used.

Long
y_skip_factor
(Optional)

The number of vertical pixels between samples.

The value must be greater than zero and less than or equal to the number of rows in the raster. The default is 1 or the last y skip factor used.

The skip factors for raster datasets stored in a file geodatabase or an ArcSDE geodatabase are different. First, if the x and y skip factors are different, the smaller skip factor will be used for both the x and y skip factors. Second, the skip factor is related to the pyramid level that most closely fits the skip factor chosen. If the skip factor value is not equal to the number of pixels in a pyramid layer, the number is rounded down to the next pyramid level, and those statistics are used.

Long
ignore_values
[ignore_value,...]
(Optional)

The pixel values that are not to be included in the statistics calculation.

The default is no value, or the last ignore values used.

Long

Code Sample

CalculateStatistics example 1 (Python window)

This is a Python sample for CalculateStatistics.

import arcpy
arcpy.CalculateStatistics_management("c:/data/image.tif", "4", "6", "0;255;21",\
                                     "SKIP_EXISTING")
CalculateStatistics example 2 (stand-alone window)

This is a Python script sample for CalculateStatistics.

##====================================
##Calculate Statistics
##Usage: CalculateStatistics_management in_raster_dataset {x_skip_factor} 
##                                      {y_skip_factor} {ignore_values;ignore_values...}
					{skip_existing}
    
try:
    import arcpy
    arcpy.env.workspace = r"\\MyMachine\PrjWorkspace\RasGP"
    
    ##Calculate Statistics for single raster dataset
    arcpy.CalculateStatistics_management("image.tif", "4", "6", "0;255;21", "OVERWRITE")

except:
    print "Calcualte Statistics example failed."
    print arcpy.GetMessages()

Environments

Related Topics

Licensing Information

ArcView: Yes
ArcEditor: Yes
ArcInfo: Yes

10/27/2014