How to create a Pansharpen function dataset (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Managing data > Working with image and raster data > Processing raster data > Function raster datasets and raster functions > How to create a Pansharpen function dataset (ArcObjects .NET 10.6 SDK)

How to create a Pansharpen function dataset


Creating a Pansharpen function dataset

To create a Pansharpen function dataset, follow these steps:
  1. Create the Function Arguments object.
  2. Specify the panchromatic and multispectral inputs.
  3. Specify the pansharpening type.
  4. Specify the pansharpening weights if needed. Pansharpening weights can be specified as arrays of double values.
  5. Create a Raster Function object for the pansharpening function.
  6. Create a Function Raster Dataset object.
  7. Create a name object for the function raster dataset.
  8. Specify the output file name for the new dataset.
  9. Initialize the new function raster dataset with the raster function and its arguments.
The following code example shows how to create a Pansharpen function raster dataset by applying the Pansharpen raster function to an image:
[C#]
// Create the Function Arguments object.
IPansharpeningFunctionArguments rasterFunctionArguments=new
    PansharpeningFunctionArgumentsClass();
// Specify the panchromatic and multispectral inputs.
// The input data can be of type IRasterDataset, IRasterBand, or IRaster.
rasterFunctionArguments.PanImage=inpDataPan;
rasterFunctionArguments.MSImage=inpDataMS;
// Specify the pansharpening type (IHS in this case).
rasterFunctionArguments.PansharpeningType =
    esriPansharpeningType.esriPansharpeningIHS;
// Pansharpening weights can be specified as arrays of double values.
IDoubleArray weightsArray=new DoubleArrayClass();
weightsArray.Add(0.166);
weightsArray.Add(0.167);
weightsArray.Add(0.166);
weightsArray.Add(0.5);
rasterFunctionArguments.Weights=weightsArray;
// Create the Raster Function object.
IRasterFunction rasterFunction=new PansharpeningFunction();
// 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\Pansharpen.afr";
functionRasterDataset.FullName=(IName)functionRasterDatasetName;
// Initialize the new Function Raster Dataset with the Raster Function and its arguments.
functionRasterDataset.Init(rasterFunction, rasterFunctionArguments);
[VB.NET]
' Create the Function Arguments object.
Dim rasterFunctionArguments As IPansharpeningFunctionArguments
rasterFunctionArguments=New PansharpeningFunctionArgumentsClass()
' Specify the panchromatic and multispectral inputs.
' The input data can be of type IRasterDataset, IRasterBand, or IRaster.
rasterFunctionArguments.PanImage=inpDataPan
rasterFunctionArguments.MSImage=inpDataMS
' Specify the pansharpening type (IHS in this case).
rasterFunctionArguments.PansharpeningType=esriPansharpeningType.esriPansharpeningIHS
' Pansharpening weights can be specified as arrays of double values.
Dim weightsArray As IDoubleArray
weightsArray=New DoubleArrayClass()
weightsArray.Add(0.166)
weightsArray.Add(0.167)
weightsArray.Add(0.166)
weightsArray.Add(0.5)
rasterFunctionArguments.Weights=weightsArray

' Create the Raster Function object.
Dim rasterFunction As IRasterFunction
rasterFunction=New PansharpeningFunction()
' 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\Pansharpen.afr"
functionRasterDataset.FullName=functionRasterDatasetName
' Initialize the new Function Raster Dataset with the Raster Function and its arguments.
functionRasterDataset.Init(rasterFunction, rasterFunctionArguments)






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):
Development licensing Deployment licensing
ArcGIS Desktop Advanced ArcGIS Desktop Advanced
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Basic ArcGIS Desktop Basic