Available with Spatial Analyst license.
Summary
Calculates the statistics for a set of raster bands.
Usage
-
The raster bands must have a common intersection. If there are none, an error occurs and no output is created.
If the extents of the raster bands are not the same, the statistics will be calculated on the common spatial extent of all the input raster bands. The cell size will be that of the maximum of the input rasters, by default; otherwise, it will depend on the Raster Analysis environment settings.
For the Compute covariance and correlation matrices parameter, the default unchecked setting (BRIEF in scripting) indicates that only the minimum, maximum, mean, and standard deviation of the input raster bands will be computed. To calculate the covariance and correlation matrices in addition to these statistics, check this option on in the tool dialog box (or use DETAILED in scripting).
A covariance matrix presents the variances of all raster bands along the diagonal from the upper left to lower right and covariances between all raster bands in the remaining entries. The correlation matrix provides the correlation coefficients between each combination of two input bands.
In the calculation of the covariance matrix, the mean value of the band is used for any input cells that are NoData.
The statistics are written to the output file in ASCII text format. The extension for the output must be .txt.
If the input is a layer created from a multiband raster with more than three bands, the operation will consider all the bands associated with the source dataset, not just the three bands that were loaded (symbolized) by the layer.
There are several ways you can specify a subset of bands from a multiband raster to use as input into the tool.
- If using the tool dialog box, browse to the multiband raster using the browse button next to Input raster bands, open the raster, and select the desired bands.
- If the multiband raster is a layer in the Table of Contents, you can use the Make Raster Layer tool to create a new multiband layer containing only the desired bands.
- You can also create a new dataset that contains only the desired bands with Composite Bands and use the resulting dataset as input to the tool.
- In Python, the desired bands can be directly specified in the tool parameter as a list.
Syntax
BandCollectionStats (in_raster_bands, out_stat_file, {compute_matrices})
Parameter | Explanation | Data Type |
in_raster_bands [in_raster_band,...] | The input raster bands. They can be integer or floating point type. | Raster Layer |
out_stat_file | The output ASCII file containing the statistics. A .txt extension is required. | File |
compute_matrices (Optional) | Specifies whether covariance and correlation matrices are calculated.
| Boolean |
Code Sample
BandCollectionStatistics example 1 (Python window)
This example calculates the statistics for a set of raster bands.
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
BandCollectionStats("redlands", "c:/sapyexamples/output/redbandstats.txt", "BRIEF")
BandCollectionStatistics example 2 (stand-alone script)
This example calculates the statistics for a set of raster bands.
# Name: BandCollectionStats_Ex_02.py
# Description: Calculates the statistics for a set of raster bands.
# 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
inRasterBand1 = "sb/sbc1"
inRasterBand2 = "sb/sbc2"
outStatFile = "C:/sapyexamples/output/bandstatfile.txt"
# Check out the ArcGIS Spatial Analyst extension license
arcpy.checkOutExtension("Spatial")
# Execute BandCollectionStats
BandCollectionStats([inRasterBand1, inRasterBand2], outStatFile, "DETAILED")
Environments
Licensing Information
- ArcGIS for Desktop Basic: Requires Spatial Analyst
- ArcGIS for Desktop Standard: Requires Spatial Analyst
- ArcGIS for Desktop Advanced: Requires Spatial Analyst