Available with Spatial Analyst license.
Summary
Calculates the statistics for a set of raster bands.
Usage
When a multiband raster is specified as one of the Input raster bands (in_raster_bands 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 raster bands (in_raster_bands in Python).
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.
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
- Basic: Requires Spatial Analyst
- Standard: Requires Spatial Analyst
- Advanced: Requires Spatial Analyst