# Raster statistics (Environment setting)

Tools that honor the Raster Statistics environment control how statistics are built for output raster datasets.

The Statistics option enables you to build statistics for the output raster dataset. Statistics are required for the raster dataset to perform certain tasks in ArcMap or ArcCatalog, such as applying a contrast stretch or classifying data. It is not essential to build statistics at this point, since they are calculated the first time they are needed, if they have not already been calculated. It is, however, recommended that you calculate raster datasets before using them if certain features that require statistics are to be used. The default display of a raster in ArcMap or ArcCatalog will be improved in most cases if statistics have already been calculated, because a standard deviation stretch is applied if statistics are present. In other cases, if the data to be displayed shouldn't be displayed with stretch by default, it would be appropriate not to calculate statistics for the dataset.

Setting a skip factor speeds up the process of calculating statistics by skipping pixels. Ignore values applies to the values that will not participate in the statistics calculation. Normally, you may want to ignore the values of the background. This setting is used for tools that create raster datasets in ArcGIS. Refer to the Raster Storage Matrix to see which raster storage formats can be controlled when using this setting.

## Usage notes

- Statistics are required for your raster dataset to perform certain tasks in ArcMap or ArcCatalog, such as applying a contrast stretch or classifying your data.
- It is recommended that you calculate your raster datasets before using them if you want to use certain features that require statistics.
- Skip factor allows you to speed up the process of calculating statistics by skipping pixels.
- Ignore values applies to the values that will not participate in the statistics calculation. Normally, you may want to ignore the values of the background.
- 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.
- Refer to the Raster Storage Matrix to see which raster storage formats can be controlled when using this setting.

## Dialog syntax

- Calculate statistics—To calculate statistics, check the check box.
- Statistics skip factor
- X skip factor—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.
- Y skip factor—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 dataset. The default is 1 or the last skip factor used.

- Statistics ignore value—An ignore value, such as a background value, that will not participate in the statistics calculation.

## Scripting syntax

arcpy.env.rasterStatistics = "calculate_statistics {x_skip_factor} {y_skip_factor} {statistics_ignore_value}"

Parameters |
Explanation |
---|---|

calculate_statistics (Required) | To calculate statistics, use STATISTICS; otherwise, specify NONE. |

x_skip_factor (Optional) |
The skip factor for the X axis. |

y_skip_factor (Optional) | The skip factor for the Y axis. |

statistics_ignore_value (Optional) | An ignore value, such as a background value, that will not participate in the statistics calculation. The ignore value is entered in round brackets. |

import arcpy # Statistics using a skip factor of 100 for x and y, and # an ignore value of 0. arcpy.env.rasterStatistics = 'STATISTICS 100 100 (0)'