Summary
Calculates statistics for a set of raster bands.
Usage
· The raster bands must have a common intersection. If there is no public intersection, an error occurs and no output is created.
· If the extents of the raster bands are different, the statistics are calculated in the common spatial extent of all the input raster bands. By default, the cell size is the largest cell size of the input raster, otherwise it will depend on the raster analysis environment settings.
· The default setting for calculating matrix parameters (BRIEF in the script, unchecked in the tool dialog box) is to calculate only the minimum, maximum, average, and standard deviation of the input raster bands. To calculate these statistics and their covariance and correlation matrices, you need to set the parameter to detailed in the script, or select it in the tool dialog box. The covariance matrix lists all the variance of all raster bands along the top left-to-right diagonal, and the covariance between all the raster bands in the remaining entries. The correlation matrix provides a correlation coefficient for each of the two input band pairs.
· In the calculation of the covariance matrix, the average of each band is used for any NoData input cells.
· The statistics are written to the output file in ASCII text format. The output must have a. txt extension.
· If you enter a layer created from a multiband raster (more than three bands), the operation takes into account all the bands associated with the source dataset, not just the three bands loaded (symbolized) by the layer.
· You can specify a subset of bands for a multiband raster as input to the tool in several ways.
· If you want to use the tool dialog box, navigate to the multi-band raster by the button next to the input raster bands, open the grid, and select the desired band.
· If the multiband raster is a layer in the table of contents, you can use the Create Raster Layer tool to create a new multiband layer that contains only the desired bands.
· You can also use band compositing to create a new dataset that contains only the desired bands and use the resulting dataset as input to the tool.
· In Python, you can specify the desired bands directly in the tool parameters as a list.
Grammar
Bandcollectionstats (In_raster_bands, Out_stat_file, {compute_matrices})
Code instance
Band SET Statistics (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")
Band SET Statistics (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")
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
ArcGIS Tutorial: Band SET Statistics