IRasterBandCollection Interface

Provides access to members that control a collection of RasterBands.

When To Use

The IRasterBandCollection interface allows you to access the raster bands that compose the raster.

Members

Name Description
Method Add Adds a RasterBand to the band collection.
Method AppendBand Appends a RasterBand to the band collection.
Method AppendBands Appends a collection of RasterBands to the band collection.
Read-only property BandByName A RasterBand given its name.
Read-only property BandIndex The index of a RasterBand given its name.
Read-only property Bands All the bands in the collection as an interface to the RasterBands enumerator object.
Method Clear Removes all the elements in the collection.
Read-only property Count The number of bands in the collection.
Method Item Returns a RasterBand given its index.
Method Remove Removes an element from the collection.
Method SaveAs Creates a new persistent RasterDataset with the bands in the collection.

IRasterBandCollection.Add Method

Adds a RasterBand to the band collection.

Public Sub Add ( _
    ByVal Element As IRasterBand, _
    ByVal Index As Integer _
)
public void Add (
    IRasterBand Element,
    int Index
);

Remarks

This method is only applicable to work with a Raster, not with a RasterDataset.

IRasterBandCollection.AppendBand Method

Appends a RasterBand to the band collection.

Public Sub AppendBand ( _
    ByVal Element As IRasterBand _
)
public void AppendBand (
    IRasterBand Element
);

Remarks

This method is only applicable to work with a Raster, not with a RasterDataset.

IRasterBandCollection.AppendBands Method

Appends a collection of RasterBands to the band collection.

Public Sub AppendBands ( _
    ByVal Bands As IRasterBandCollection _
)
public void AppendBands (
    IRasterBandCollection Bands
);

Remarks

This method is only applicable to work with a Raster, not with a RasterDataset.

IRasterBandCollection.BandByName Property

A RasterBand given its name.

Public Function get_BandByName ( _
    ByVal Name As String _
) As IRasterBand
public IRasterBand get_BandByName (
    string Name
);

IRasterBandCollection.BandIndex Property

The index of a RasterBand given its name.

Public Function get_BandIndex ( _
    ByVal Name As String _
) As Integer
public int get_BandIndex (
    string Name
);

IRasterBandCollection.Bands Property

All the bands in the collection as an interface to the RasterBands enumerator object.

Public ReadOnly Property Bands As IEnumRasterBand
public IEnumRasterBand Bands {get;}

IRasterBandCollection.Clear Method

Removes all the elements in the collection.

Public Sub Clear ( _
)
public void Clear (
);

Remarks

This method is only applicable to work with a Raster, not with a RasterDataset.

IRasterBandCollection.Count Property

The number of bands in the collection.

Public ReadOnly Property Count As Integer
public int Count {get;}

IRasterBandCollection.Item Method

Returns a RasterBand given its index.

Public Function Item ( _
    ByVal BandIndex As Integer _
) As IRasterBand
public IRasterBand Item (
    int BandIndex
);

IRasterBandCollection.Remove Method

Removes an element from the collection.

Public Sub Remove ( _
    ByVal Index As Integer _
)
public void Remove (
    int Index
);

Remarks

This method is only applicable to work with a Raster, not with a RasterDataset.

IRasterBandCollection.SaveAs Method

Creates a new persistent RasterDataset with the bands in the collection.

Public Function SaveAs ( _
    ByVal new_name As String, _
    ByVal worksp As IWorkspace, _
    ByVal Format As String _
) As IDataset
public IDataset SaveAs (
    string new_name,
    IWorkspace worksp,
    string Format
);

Functional License Check

If your application/site is not appropriately licensed, SaveAs can return an error of E_RASTER_FILE_LZW_FAILED.

Remarks

The SaveAs method can create a raster dataset in Imagine, TIFF, GRID, JPEG2000, JPEG, BMP, GIF, PNG, PCI Raster, USGS ASCII DEM, X11 Pixmap, Memory Raster and geodatabase raster.

The format strings used for the supported formats are below, and they are case sensitive:

Format Name String Used
Imagine "IMAGINE Image"
TIFF "TIFF"
GRID "GRID"
JPEG "JPG"
JP2000 "JP2"
BMP "BMP"
PNG "PNG"
GIF "GIF"
PCI Raster "PIX"
X11 Pixmap "XPM"
PCRaster "MAP"
Memory Raster "MEM"
HDF4 "HDF4"
BIL "BIL"
BIP "BIP"
BSQ "BSQ"
Idrisi Raster Format "RST"
ENVI Raster Format "ENVI"
Geodatabase Raster "GDB"

The format string "TIFF" creates a TIFF file with ".tif" extension. ArcGIS also supports TIFF format with ".tiff" and ".tff" extensions. A format string "TIF" creates a TIFF file with ".tiff" extention and a format string "TFF" creates a TIFF file with ".tff" extension.

Note, SaveAs will return a RasterDataset, to prevent from SaveAs holding the output, .NET ReleaseCOMObject needs to be called to release the referene to the output raster dataset:

System.Runtime.InteropServices.Marshal.ReleaseComObject(outRasterDS);

Classes that implement IRasterBandCollection

Classes Description
FunctionRasterDataset A class for a function raster dataset.
Raster An in-memory representation of a dynamic raster that can perform resampling and reprojection.
RasterDataset A representation of a raster dataset on disk.

Remarks

IRasterBandCollection interface is used to manage and access a collection of raster bands of a RasterDataset or a Raster

The Add, Remove, Clear, AppendBand and AppenBands methods only applicable to IRasterBandCollection on a Raster, not on a RasterDataset.

When a band is added to or removed from a Raster object, the Raster recomputes a default cell size, extent, and spatial reference based on the bands in the Raster. If the user has not explicitly set these properties, the default settings will be applied to the raster object.

The spatial reference is determined first. If the user has not specified a spatial reference system to be applied to the raster, it is calculated from the first band in the raster that has a spatial reference other than unknown. If all bands have an unknown spatial reference, the spatial reference system of the raster will be unknown.

Next the cell size is calculated, if the cell size and number of rows and columns have not been specified by the user. The cell size is the maximum cell size of any input bands projected into the current spatial reference system. If no spatial reference system is known, the largest cell size of any band in the Raster is selected.

Finally, if the extent has not been specified by the user, it is calculated. The extent is the smallest bounding box with an integer number of rows and columns that can be placed around all bands of the input raster while aligning with the bottom-left corner of the Raster.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.