Implementing an algorithm using functions in a mosaic dataset
This workflow will describe how to combine functions in a mosaic dataset to create an NDVI. There is an NDVI function available that will apply a scale and offset to allow it to be visualized; however, if you want the raw NDVI values, which range between -1.0 and 1.0, you will have to implement the steps below.
You will apply the function on the mosaic dataset, not on the individual rasters within the mosaic dataset.
The algorithm for NDVI is as follows:
NDVI = ((IR - R)/(IR+R))where
IR = infrared band
R = red band
This will result in the following layout on the Function tab.
The workflow is broken up according to each input and action. The following lists the order you would use to calculate the algorithm, but when you chain the functions together, you will start with the result and work toward the inputs, as you can see in the diagram above.
- Define the band inputs: IR and R
- Subtract one from the other: IR - R
- Add them together: IR + R
- Divide them: (IR - R) / (IR + R)
Set up the mosaic dataset
You will be applying the functions on a mosaic dataset. Therefore, you need to create a mosaic dataset and add all your raster data. It is assumed that the data has the same bands for the infrared and red bands. In this example, assume that the infrared band is band 1, and the red band is band 2.
- Create a mosaic dataset.
-
Add your raster data to the mosaic dataset.
Be sure to build the overviews.
Chain the arithmetic functions
-
Add your mosaic dataset to the ArcMap display.
You can add the mosaic dataset now or at the very end. You add it to ArcMap to view the result in the Image layer. Your mosaic dataset may already be open in ArcMap if you've just finished creating it.
- Open the Catalog Window and navigate to the mosaic dataset.
- Right-click the mosaic dataset and click Properties.
-
Click the Functions tab.
You see the following function chain with the single Mosaic function listed. The Mosaic function is listed by default because this is a mosaic dataset and all rasters are being mosaicked. It is after the mosaicking that you will be applying your algorithm.
-
Right-click the Mosaic Function and click Insert > Arithmetic Function.
When you insert a function, it is inserted above the function you've clicked.
This opens the Raster Functions Properties dialog box, which allows you to set the options for this function.
-
Click the Operation drop-down arrow and click Divide.
The inputs will remain as they are. The input is added to the function chain when you close this dialog box.
- Click the General tab.
- Type Divide in the Function Name text box.
-
Click the Output Pixel Type drop-down arrow and click 32 Bit Float.
The output of this algorithm is values ranging from -1 to 1. You need to specify the pixel type; otherwise, you may end up with pixel values that equal the inputs, such as 8-bit.
-
Click OK.
The Divide function is added to the top of the function chain, and another Mosaic function is added, since this arithmetic function requires two inputs.
- Right-click the top Mosaic Function in the function chain and click Insert > Arithmetic Function.
-
Click the Operation drop-down arrow and click Minus.
The inputs remain as they are. The input will be added to the function chain when you close this dialog box.
- Click the General tab.
- Type Minus in the Function Name text box.
- Click the Output Pixel Type drop-down arrow and click 32 Bit Float.
-
Click OK.
The Minus function is added after the Divide function, and two inputs are added underneath named Mosaic Function.
- Right-click the bottom Mosaic Function in the function chain and click Insert > Arithmetic Function.
-
Click the Operation drop-down arrow and click Plus.
The inputs remain as they are. The input is added to the function chain when you close this dialog box.
- Click the General tab.
- Type Plus in the Function Name text box.
- Click the Output Pixel Type drop-down arrow and click 32 Bit Float.
-
Click OK.
The Plus function is added to the bottom at the same level as the Minus function, and two inputs are added underneath named Mosaic Function.
Define the inputs to the arithmetic functions
The functions that will be used to do the arithmetic have been added; next, you have to identify the inputs. These are the IR and R bands—bands 1 and 2, consecutively (as defined earlier). To do this, use the Extract Bands function.
-
Right-click the top Mosaic Function under the Minus function and click Insert > Extract Band Function.
- Type 1 in the Band IDs text box.
- Click the General tab.
- Type Extract IR in the Function Name text box.
-
Click OK.
The Extract IR function is added to the function chain, and a Mosaic Function is added to it as an input.
- Right-click the other Mosaic Function under the Minus function and click Insert > Extract Band Function.
- Type 2 in the Band IDs text box.
- Click the General tab.
- Type Extract Red in the Function Name text box.
-
Click OK.
The Extract Red function is added to the function chain, and a Mosaic Function is added to it as an input.
-
Repeat these steps for the inputs under the Plus function.
You end up with a function chain that looks like the one at the top of this topic.
- Click OK to close the Mosaic Dataset Properties dialog box.
Once you've finished adding these functions, you can preview the mosaicked image. You many need to calculate the statistics of the mosaic dataset, since it's been altered to contain a 32-bit output. You can use the Calculate Statistics tool.
You can examine the pixel values using the Identify tool or the Pixel Inspector.