ArcGIS Blog

Imagery & Remote Sensing

ArcGIS Pro

Create universal classified raster function templates

By Guenter Doerffel

Use ArcGIS Pro UI capabilities first to define your classification, then use a little custom GP tool to convert the result to a generic raster function template for ArcGIS Pro, ArcGIS Image Server, and ArcGIS Online Image Services.
 

Raster classification and a meaningful legend help you understand data and communicate results. The ArcGIS Pro classify raster workflow supports you in defining meaningful classification for any raster layer. With the help of a custom tool, the result can then be used across the ArcGIS system.

Disclaimers

The toolbox provided only supports the Classify renderer.

Classify renderer category supported

Though it accepts all color models defined in the input, the output color model is always translated to RGB plus Alpha.

Sample input color model HSV
Sample input color model HSV
Output always RGB
Output always RGB

The Toolbox is provided “as is” to show what can be done. It is not supported and will not be guaranteed to be maintained or updated.

Create a classified raster template

Complete the following steps to create a base template:

  1. Add any raster to ArcGIS Pro that contains suitable data for classification.
    This could be elevation, velocity, temperature, or another type of data that already is classified into unique values that you want to display in a certain way.
  2.  

  3. Set the layer to display in Stretch mode, so the capabilities of classification are available in ArcGIS Pro.
  4.  

    Sample data layer of elevation data, displayed in Stretch mode
    Sample data layer of elevation data, displayed in Stretch mode
  5. Open the Symbology pane for this layer and switch to the Classify category to define a classification to use.
  6.  

    Symbology pane and Classify category to select
    Symbology pane and Classify category to select

    The symbology of the layer switches to a default classification that you can adjust. Learn more about symbology for imagery in the help documentation.

     

    For example, assume this is the classification wanted:

    Classification defined in Symbology pane
    Classification defined in Symbology pane
  7. Export this classification into a raster function template in the Symbology pane.
  8.  

    Option to save current classification as a raster function template
    Option to save current classification as a raster function template
  9. In the Raster Functions pane, name and categorize the template in the custom raster functions section.
  10.  

  11. Use the standard export capability to export the template to an .rft file stored on disk. See Export symbology as a raster function template.
  12.  

    Option to export raster function to disk
    Option to export raster function to disk
    Defined output location and name
    Defined output location and name

    If you open the exported .rft.xml file in a text editor, you see that the classes, legend items, and color definitions are encoded inside a rendered raster function, which is a noneditable ArcGIS internal raster function. Consequently, when loading this raster function template into the raster function template editor, the model will look similar to the following:

    The exported raster function template with the rendered raster function
    The exported raster function template with the rendered raster function

    When you double-click the Rendered Raster box, you will not see your classification in the UI. When applying the raster function in ArcGIS Pro, Image Server, or ArcGIS Online, the data will show the right classification, but the legend will only display as a standard RGB legend:

    Resulting RGB legend of exported Raster Function
    Resulting RGB legend of exported Raster Function

    ArcGIS Pro allows you to classify rasters and define the class properties – which can be stored in raster function templates with the rendered raster function – but reapplying this function does not return the full legend.
    Alternatively, you can combine the Remap and Attribute Table raster functions, which is less versatile in defining the classes and symbols, but will return the full legend when applied.
    The solution is to map the rendered raster .xml file to the remap and attribute table .xml file, which you can do using the sample tool, but only for Classify renderers.

  13. To proceed, download the encrypted Python toolbox from ArcGIS Online, save it, and add it to ArcGIS Pro as a toolbox, resulting in this view in the Catalog pane:
  14.  

    Python toolbox after adding it to ArcGIS Pro
    Python toolbox after adding it to ArcGIS Pro
  15. Run the CIM Classes to Remap rft Converter script tool.
  16.  

  17. Specify the raster function template you exported as the input you want to convert.
  18.  

    After adding the .rft file, a requirements check and analysis will be performed and reported in the File Information text line. If the .rft file does not pass this test, it cannot be converted.

    Input section to specify .rft file to convert
    Input section to specify .rft file to convert
  19. In the File Outputs section, specify an output .rft file, or keep the default. Optionally, you can output .csv files that represent the remap table and the attribute table generated and used after conversion.
  20.  

    Fields to specify outputs
    Fields to specify outputs
  21. Optionally, in the final section of the tool, set arguments and capabilities:
  22.  

    Optional Arguments section
    Optional Arguments Section
    1. Specify the number of decimal places.
      For a clearer legend display, the values can be rounded by the specified number of decimals.
    2. Type a name for the template to display in ArcGIS Pro, ArcGIS Server, and ArcGIS Online.
    3. Set the legend header text to display. However, see the note below before editing this value.
    4. Type a measurement unit string that will be added to the legend values.

     

    In this example, with the settings applied above, the resulting template is now converted and stored on disk.

  23. Import it back into ArcGIS Pro as a custom raster function template, upload it to ArcGIS Online, or apply it to datasets to serve with Image Server.
  24.  

Importing the converted RFT in ArcGIS Pro
Importing the converted RFT in ArcGIS Pro

When you open it in the raster function editor, you will now see the Remap and Attribute Table function boxes.

Converted RFT, now showing Remap and Attribute Table function boxes
Converted RFT, now showing Remap and Attribute Table function boxes

When applying the function chain to the original raster (again, based on the stretch display of it), the display and legend now look similar to the following:

Resulting layer using the converted raster function
Resulting layer using the converted raster function

In this screenshot, you can see the following:

  1. The legend header is what you specified in the Legend Header String parameter of the tool.
  2. The numbers are rounded to the number of decimals specified in the Decimal Places parameter.
  3. There is a unit string added after every value as specified in the Unit String parameter.

 

The resulting template can be used–and will behave identically–in ArcGIS Pro, with Image Services, and with ArcGIS Online raster services.

 
Note: The default value for the Legend Header String parameter is ClassName. Changing it with this tool will result in a working raster function template; however, you cannot edit the attribute table function in the raster function template editor, as the name of the node in the .xml file is not recognized by the editor. If you intend to edit the attribute table interactively, leave the Legend Header String parameter set to ClassName.

Interested in other articles on ArcGIS Imagery Capabilities?
How about reading Unlocking the Power of Image Analysis in ArcGIS Pro: What You Might Not Know

Share this article

Leave a Reply