ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Data.Raster Namespace / RasterDataset Class / GetBandIndex Method
Name of a band in this raster dataset.
Example

In This Topic
    GetBandIndex Method
    In This Topic
    Gets the index for a band in this raster dataset based on the band name. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public int GetBandIndex( 
       string name
    )
    Public Function GetBandIndex( _
       ByVal name As String _
    ) As Integer

    Parameters

    name
    Name of a band in this raster dataset.

    Return Value

    An integer representing the band index based on the band name.
    Example
    Access the bands in a raster dataset
    var count = rasterDataset.GetBandCount();
    RasterBand rasterBandByName = rasterDataset.GetBandByName(sBandName);
    var index = rasterDataset.GetBandIndex(sBandName);
    
    // Get a RasterBand from the raster dataset
    RasterBand rasterBand = rasterDataset.GetBand(0);
    
    // Get the RasterBandDefinition from the raster band.
    RasterBandDefinition rasterBandDefinition = rasterBand.GetDefinition();
    // Get the name of the raster band from the raster band.
    string bandName = rasterBandDefinition.GetName();
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also