Skip to content
jdrisdelle edited this page Oct 3, 2014 · 44 revisions

Image Processing and Analysis

Raster functions are operations that process imagery and raster datasets by applying the processing directly to the pixels. Imagine you have imagery of the entire world and you want to calculate the Normalized Difference Vegetation Index (NDVI), which uses the following equation:

               (Near Infrared – Red) / (Near Infrared + Red)

The traditional approach is to take the red and near infrared bands, perform this calculation, and write that into a new raster that shows NDVI. Remember, this is global imagery. If you’re only interested in a specific location, why create a raster for the entire globe? What a raster function does is apply that calculation to the pixel on the original data as it is drawn so it is only processing the pixels that are visible on your screen. As you zoom and pan around, the calculations are performed on the fly and no intermediate datasets are created. Why stop at NDVI? You can use functions to create many different information layers which all use the same underlying dataset.

ArcGIS comes with over over 100 out of the box functions that can be used for radiometric and geometric correction, data management, visualization, and analysis. Functions can be applied individually or combined to create function chains. There are several methods for applying functions depending on the structure of the dataset.

There are several methods for applying functions depending on the structure of the dataset.

Type of dataset Application method
Raster dataset or raster product Use the f(x) button in the Image Analysis Window.
Mosaic dataset Use the property windows.
Image Service Directly publish functions with the image service or allow the end user to apply them.

The Python Raster Function

With ArcGIS it is also possible to create custom functions. This can be done using the Python Raster function. The Python Raster Function allows users to write image processing algorithms in Python and apply them to mosaic datasets and raster datasets. The Python adapter function can be inserted into a function chain just like any other function. It accepts one of two inputs; a .py file or a .pyd (complied Cython) file. The parameters for the function are controlled within the Python script, therefore end users can simply point to a script and the function dialog will be populated.

Using the Python Raster Function

The Python raster function can be inserted into a function chain by right clicking on an existing function or raster in the function dialog. Unlike the out of the box functions, it is located in the first dialog after right clicking on an existing function. The Python Raster Function dialog has three components; the input Python module, the class name and the input parameters.

Python Raster Function: Property Page

The input Python module parameter will accept a Python script (.py) or a Cython file (.pyd). These files must adhere to the structure of the Python raster function. After pointing to a Python file the rest of the dialog will be populated.

The class name parameter will contain the name of the class being used from the python script. In most cases a Python script will contain one class. It is possible to have multiple classes in one Python script. At this point the end user can type in which class they would like to use. By default the first class in the script will be used.

The parameters window contains the parameters that are defined by the Python script. The values of the parameters can be set by the end user. There are 5 possible data types that can be used as parameters; numeric, string, raster, rasters and boolean. Domains can be created for parameters in order to limit the list of input values that a user can chose from. In this case when clicking on the value a drop down menu will appear. For more information on the method that controls input parameters go to the .getParameterInfo() section of the help document.

If the parameter type is set to rasters a user can click on the value section of the parameter and a second window will open. This window allows you to add rasters from multiple sources. The following options are available when adding rasters from this dialog.

Python Raster Function: Multiple Rasters

  • Add raster from disk: Add a raster that is on disk. You can add raster datasets, mosaic datasets, and raster products.
  • Add function chain: Add a function chain as an input.
  • Add scalar: Add a scalar value. Scalar values must be numeric.
  • Add reference to selected input: Add a referenced copy of the selected raster or the selected function chain input. A change in the referenced raster or the function chain will be reflected in this referenced copy. This can be useful when creating many Local functions that may use the same referenced input.
  • Add copy of selected input: Add a static copy of the selected function chain input. A change in the copied function chain will not reflect this static copy. This can be useful when creating many similar Local functions where there is a slight change in the function chains.