Creating a CompositeBand function dataset
To create a CompositeBand function dataset, follow these steps:
- Create an esriSystem array.
- Pick the first band from three rasters and add them to the array.
- Create a Raster Function object.
- Create a Function Raster Dataset object.
- Create a name object for the function raster dataset.
- Specify the output file name for the new dataset.
- Initialize the new function raster dataset with the raster function and its arguments.
The following code example shows how to create a CompositeBand function raster dataset by applying the CompositeBand raster function to an image:
[C#] // Create an array.
ESRI.ArcGIS.esriSystem.Array compBandArguments=new ESRI.ArcGIS.esriSystem.Array();
// Pick the first band from three rasters and add them to the array.
// The input rasters can be of type IRasterDataset or IRaster.
compBandArguments.Add(((IRasterBandCollection)rasterDataset1).Item(0));
compBandArguments.Add(((IRasterBandCollection)rasterDataset2).Item(0));
compBandArguments.Add(((IRasterBandCollection)rasterDataset3).Item(0));
// Create the Raster Function object.
IRasterFunction rasterFunction=new CompositeBandFunctionClass();
// Create the Function Raster Dataset object.
IFunctionRasterDataset functionRasterDataset=new FunctionRasterDataset();
// Create a name object for the Function Raster Dataset.
IFunctionRasterDatasetName functionRasterDatasetName=(IFunctionRasterDatasetName)
new FunctionRasterDatasetName();
// Specify the output file name for the new dataset (including the .afr extension at the end).
functionRasterDatasetName.FullName=@"c:\temp\CompositeBand.afr";
functionRasterDataset.FullName=(IName)functionRasterDatasetName;
// Initialize the new Function Raster Dataset with the Raster Function and its arguments.
functionRasterDataset.Init(rasterFunction, compBandArguments);
[VB.NET] ' Create an array.
Dim compBandArguments As ESRI.ArcGIS.esriSystem.Array
compBandArguments=New ESRI.ArcGIS.esriSystem.Array()
' Pick the first band from three rasters and add them to the array.
' The input data can be of type IRasterDataset or IRaster.
compBandArguments.Add((rasterDataset1).Item(0))
compBandArguments.Add((rasterDataset2).Item(0))
compBandArguments.Add((rasterDataset3).Item(0))
' Create the Raster Function object.
Dim rasterFunction As IRasterFunction
rasterFunction=New CompositeBandFunctionClass()
' Create the Function Raster Dataset object.
Dim functionRasterDataset As IFunctionRasterDataset
functionRasterDataset=New FunctionRasterDataset()
' Create a name object for the Function Raster Dataset.
Dim functionRasterDatasetName As IFunctionRasterDatasetName
functionRasterDatasetName=New FunctionRasterDatasetName()
' Specify the output file name for the new dataset (including the .afr extension at the end).
functionRasterDatasetName.FullName="c:\temp\CompositeBand.afr"
functionRasterDataset.FullName=functionRasterDatasetName
' Initialize the new Function Raster Dataset with the Raster Function and its arguments.
functionRasterDataset.Init(rasterFunction, compBandArguments)
To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
- ESRI.ArcGIS.DataSourcesRaster
- ESRI.ArcGIS.Geodatabase
- ESRI.ArcGIS.System (ESRI.ArcGIS.esriSystem)
Development licensing | Deployment licensing |
---|---|
ArcGIS Desktop Advanced | ArcGIS Desktop Advanced |
ArcGIS Desktop Standard | ArcGIS Desktop Standard |
ArcGIS Desktop Basic | ArcGIS Desktop Basic |