How to use
See How to use ArcGIS samples for help on compiling, setting up the debugger, and running the sample. If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.
Setting up the custom function
- Start Visual Studio and open the solution.
- Build the NDVICustomFunction and NDVICustomFunctionUI projects.
- The function can now be used like any of the built-in functions in the system.
Updating XmlSupport.dat to serialize functions to and from XML
- Open the XmlSupportSubsetNC.dat file in the TestNDVICustomFunction folder. Copy its contents.
- Open <Program Files>\ArcGIS\<Desktop Directory>\bin\XmlSupport.dat. This is an XML file containing types that can be serialized to and from an XML file. Create a backup of the file.
- Paste the contents copied in Step 1 inside the main node of the XML along with the other type entries. Make sure it's between type nodes and not inside one.
- Save the XMLSupport.dat file.
Using the custom function in desktop
- Start ArcMap.
- Open the raster dataset on which the function is to be applied.
- Open the Image Analysis window.
- Select the raster dataset on which the function is to be applied in the topmost section.
- In ArcGIS 10.0, under the Processing section, click the Clip button, open the properties of the newly created layer, then navigate to the functions tab. The function editor opens. Right-click the Clip function and click Remove.
- In ArcGIS 10.1 and after, under the Processing section, click the fx button. The function editor opens.
- Right-click the dataset and open the Insert menu, then click the NDVI Custom function. This opens the NDVI Function UI page, which allows you to set the parameter.
- Input the band indexes for the NIR and Red bands separated by a space.
- Click OK.
- In ArcGIS 10.0, the layer now represents the output of the custom function applied to the raster dataset.
- In ArcGIS 10.1 and after, a new layer is created that represents the output of the custom function applied to the raster dataset.
Using the custom function test application
- Start Visual Studio and open the solution file.
- Open the TestNDVICustomFunction project.
- Set the flags to add the NDVI Custom function on top of a raster dataset and a mosaic dataset, to serialize a Raster Function template containing the custom function to an XML file, or to deserialize an XML file back to a function template containing the custom function.
- Edit the strings in the Specify inputs region to specify the directory and name of the input dataset, the Geodatabase and name of the mosaic dataset, the output directory, the name of the output dataset (including the .afr extension), and the full path to the XML file to write out or read from if needed.
- Set the parameters for the NDVI Custom function (that is, indexes of the NIR and Red band delimited by spaces).
- Compile and run the program. If the program succeeds, the console shows a Success message. If an error occurs, it shows on the console window.
- If adding on top of a raster dataset, load the created output .afr file into an ArcMap or ArcCatalog dataset. An image that represents the output of the custom function applied to the raster dataset appears.
- If adding on top of a mosaic dataset, load the mosaic dataset to which the custom function was added in ArcMap or ArcCatalog. An image that represents the output of the custom function applied to the raster dataset appears.
NDVICustomFunction\NDVICustomFunction.cs | Source file that implements the custom raster function. |
NDVICustomFunctionUI\NDVICustomFunctionUIClass.cs | Source file that implements the custom raster function UI. |
TestNDVICustomFunction\TestNDVICustomFunction.cs | Source file for the test application that can be used to apply the custom function to a raster dataset or a mosaic dataset. |
NDVICustomFunction\NDVICustomFunction.vb | Source file that implements the custom raster function. |
NDVICustomFunctionUI\NDVICustomFunctionUIClass.vb | Source file that implements the custom raster function UI. |
TestNDVICustomFunction\TestNDVICustomFunction.vb | Source file for the test application that can be used to apply the custom function to a raster dataset or a mosaic dataset. |
Download the files for all languages
Development licensing | Deployment licensing |
---|---|
ArcGIS for Desktop Basic | ArcGIS for Desktop Basic |
ArcGIS for Desktop Standard | ArcGIS for Desktop Standard |
ArcGIS for Desktop Advanced | ArcGIS for Desktop Advanced |
Engine Developer Kit | Engine |