How to create an NDVI function dataset


Creating an NDVI function dataset

To create a Normalized Difference Vegetation Index (NDVI) function dataset, follow these steps:
  1. Create the Raster Function object.
  2. Create the Function Raster Dataset object.
  3. Create a name object for the function raster dataset.
  4. Specify the output file name for the new dataset.
The following code example shows how to create an NDVI function raster dataset by applying the NDVI raster function to an image:
[C#]
// Create the Raster Function object.
IRasterFunction rasterFunction = new NDVIFunctionClass();
// 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\NDVIFunction.afr";
functionRasterDataset.FullName = (IName)functionRasterDatasetName;
// The input data can be of type IRasterDataset, IRasterBand, or IRaster.
// The input data for an NDVI function is a raster with its first two bands as the infrared 
// and near-infrared bands, respectively.
functionRasterDataset.Init(rasterFunction, inputData);
[VB.NET]
' Create the Raster Function object.
Dim rasterFunction As IRasterFunction
rasterFunction = New NDVIFunctionClass()
' 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\NDVIFunction.afr"
functionRasterDataset.FullName = functionRasterDatasetName
' The input data can be of type IRasterDataset, IRasterBand, or IRaster.
' The input data for an NDVI function is a raster with its first two bands as the infrared
' and near-infrared bands, respectively.
functionRasterDataset.Init(rasterFunction, inputData)






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 for Desktop Advanced ArcGIS for Desktop Advanced
ArcGIS for Desktop Standard ArcGIS for Desktop Standard
ArcGIS for Desktop Basic ArcGIS for Desktop Basic