Creating a Mask function dataset
To create a Mask function dataset, follow these steps:
- Create the Function Arguments object.
- Specify the include ranges using a double array. The first two values in the array correspond to the minimum and maximum range to include for the first band.
- 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 Mask function raster dataset by applying the Mask raster function to an image:
[C#] // Create the Function Arguments object.
IMaskFunctionArguments rasterFunctionArguments=(IMaskFunctionArguments)new
MaskFunctionArgumentsClass();
// Specify the include ranges for each band.
IDoubleArray includeRanges=new DoubleArrayClass();
includeRanges.Add(100.0); // Min for Band 1
includeRanges.Add(200.0); // Max for Band 1
includeRanges.Add(100.0); // Min for Band 2
includeRanges.Add(200.0); // Max for Band 2
includeRanges.Add(100.0); // Min for Band 3
includeRanges.Add(200.0); // Max for Band 3
rasterFunctionArguments.IncludedRanges=includeRanges;
// The input data can be of type IRasterDataset, IRasterBand, or IRaster.
rasterFunctionArguments.Raster=inputData;
// Create the Raster Function object.
IRasterFunction rasterFunction=new MaskFunction();
// 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\Mask.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 IMaskFunctionArguments =
(IMaskFunctionArguments) New MaskFunctionArgumentsClass()
' Specify the include ranges for each band.
Dim includeRanges As IDoubleArray=New DoubleArrayClass()
includeRanges.Add(100R) ' Min for Band 1
includeRanges.Add(200R) ' Max for Band 1
includeRanges.Add(100R) ' Min for Band 2
includeRanges.Add(200R) ' Max for Band 2
includeRanges.Add(100R) ' Min for Band 3
includeRanges.Add(200R) ' Max for Band 3
rasterFunctionArguments.IncludedRanges=includeRanges
' The input data can be of type IRasterDataset, IRasterBand, or IRaster.
rasterFunctionArguments.Raster=inputData
' Create the Raster Function object.
Dim rasterFunction As IRasterFunction=New MaskFunction()
' Create the Function Raster Dataset object.
Dim functionRasterDataset As IFunctionRasterDataset=New FunctionRasterDataset()
' Create a name object for the Function Raster Dataset.
Dim functionRasterDatasetName As IFunctionRasterDatasetName
' Specify the output file name for the new dataset (including the .afr extension at the end).
functionRasterDatasetName.FullName="c:\temp\Mask.afr"
functionRasterDataset.FullName=DirectCast(functionRasterDatasetName, IName)
' 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):
- ESRI.ArcGIS.DataSourcesRaster
- ESRI.ArcGIS.Geodatabase
- ESRI.ArcGIS.System (ESRI.ArcGIS.esriSystem)
Development licensing | Deployment licensing |
---|---|
ArcGIS for Desktop Advanced | ArcGIS for Desktop Advanced |
ArcGIS for Desktop Standard | ArcGIS for Desktop Standard |
ArcGIS for Desktop Basic | ArcGIS for Desktop Basic |