ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / StretchColorizerDefinition Class
Members Example

In This Topic
    StretchColorizerDefinition Class
    In This Topic
    Represents a colorizer definition for a Stretch colorizer that allows you to define the range of values to be displayed and apply a color ramp to those values.
    Object Model
    StretchColorizerDefinition ClassCIMColor ClassCIMColorRamp ClassCIMColor Class
    Syntax
    public class StretchColorizerDefinition : RasterColorizerDefinition 
    Public Class StretchColorizerDefinition 
       Inherits RasterColorizerDefinition
    Remarks
    The StretchColorizerDefinition class allows you to define a simplified list of parameters to create a Stretch colorizer. Once you define a Stretch colorizer definition, you can call the BasicRasterLayer.CreateColorizer and BasicRasterLayer.SetColorizer methods to create and assign a Stretch colorizer to a BasicRasterLayer.
    Example
    Create a new colorizer based on a default colorizer definition and apply it to the raster layer
    await QueuedTask.Run(async () =>
    {
      // Check if the Stretch colorizer can be applied to the raster layer.
      if (rasterLayer.GetApplicableColorizers().Contains(RasterColorizerType.StretchColorizer))
      {
        // Create a new Stretch Colorizer Definition using the default constructor.
        StretchColorizerDefinition stretchColorizerDef_default = new StretchColorizerDefinition();
        // Create a new Stretch colorizer using the colorizer definition created above.
        CIMRasterStretchColorizer newStretchColorizer_default =
          await rasterLayer.CreateColorizerAsync(stretchColorizerDef_default) as CIMRasterStretchColorizer;
        // Set the new colorizer on the raster layer.
        rasterLayer.SetColorizer(newStretchColorizer_default);
      }
    });
    Create a new colorizer based on a custom colorizer definition and apply it to the raster layer
    await QueuedTask.Run(async () =>
    {
      // Check if the Stretch colorizer can be applied to the raster layer.
      if (rasterLayer.GetApplicableColorizers().Contains(RasterColorizerType.StretchColorizer))
      {
        // Create a new Stretch Colorizer Definition specifying parameters 
        // for band index, stretch type, gamma and color ramp.
        StretchColorizerDefinition stretchColorizerDef_custom =
          new StretchColorizerDefinition(1, RasterStretchType.ESRI, 2, colorRamp);
        // Create a new stretch colorizer using the colorizer definition created above.
        CIMRasterStretchColorizer newStretchColorizer_custom =
          await rasterLayer.CreateColorizerAsync(stretchColorizerDef_custom) as CIMRasterStretchColorizer;
        // Set the new colorizer on the raster layer.
        rasterLayer.SetColorizer(newStretchColorizer_custom);
      }
    });
    Create a new colorizer based on a default colorizer definition and apply it to the mosaic layer
    await QueuedTask.Run(async () =>
    {
      // Get the image sub-layer from the mosaic layer.
      ImageMosaicSubLayer mosaicImageSubLayer = mosaicLayer.GetImageLayer();
      // Check if the Stretch colorizer can be applied to the image sub-layer.
      if (mosaicImageSubLayer.GetApplicableColorizers().Contains(RasterColorizerType.StretchColorizer))
      {
        // Create a new Stretch Colorizer Definition using the default constructor.
        StretchColorizerDefinition stretchColorizerDef_default = new StretchColorizerDefinition();
        // Create a new Stretch colorizer using the colorizer definition created above.
        CIMRasterStretchColorizer newStretchColorizer_default =
          await mosaicImageSubLayer.CreateColorizerAsync(stretchColorizerDef_default) as CIMRasterStretchColorizer;
        // Set the new colorizer on the image sub-layer.
        mosaicImageSubLayer.SetColorizer(newStretchColorizer_default);
      }
    });
    Create a new colorizer based on a custom colorizer definition and apply it to the mosaic layer
    await QueuedTask.Run(async () =>
    {
      // Get the image sub-layer from the mosaic layer.
      ImageMosaicSubLayer mosaicImageSubLayer = mosaicLayer.GetImageLayer();
      // Check if the Stretch colorizer can be applied to the image sub-layer.
      if (mosaicImageSubLayer.GetApplicableColorizers().Contains(RasterColorizerType.StretchColorizer))
      {
        // Create a new Stretch colorizer definition specifying parameters
        // for band index, stretch type, gamma and color ramp.
        StretchColorizerDefinition stretchColorizerDef_custom =
          new StretchColorizerDefinition(1, RasterStretchType.ESRI, 2, colorRamp);
        // Create a new stretch colorizer using the colorizer definition created above.
        CIMRasterStretchColorizer newStretchColorizer_custom =
          await mosaicImageSubLayer.CreateColorizerAsync(stretchColorizerDef_custom) as CIMRasterStretchColorizer;
        // Set the new colorizer on the image sub-layer.
        mosaicImageSubLayer.SetColorizer(newStretchColorizer_custom);
      }
    });
    Create a new colorizer based on a default colorizer definition and apply it to the image service layer
    await QueuedTask.Run(async () =>
    {
      // Check if the Stretch colorizer can be applied to the image service layer.
      if (isLayer.GetApplicableColorizers().Contains(RasterColorizerType.StretchColorizer))
      {
        // Create a new Stretch Colorizer Definition using the default constructor.
        StretchColorizerDefinition stretchColorizerDef_default = new StretchColorizerDefinition();
        // Create a new Stretch colorizer using the colorizer definition created above.
        CIMRasterStretchColorizer newStretchColorizer_default =
          await isLayer.CreateColorizerAsync(stretchColorizerDef_default) as CIMRasterStretchColorizer;
        // Set the new colorizer on the image service layer.
        isLayer.SetColorizer(newStretchColorizer_default);
      }
    });
    Create a new colorizer based on a custom colorizer definition and apply it to the image service layer
    await QueuedTask.Run(async () =>
    {
      // Check if the Stretch colorizer can be applied to the image service layer.
      if (isLayer.GetApplicableColorizers().Contains(RasterColorizerType.StretchColorizer))
      {
        // Create a new Stretch Colorizer Definition specifying parameters
        // for band index, stretch type, gamma and color ramp. 
        StretchColorizerDefinition stretchColorizerDef_custom =
          new StretchColorizerDefinition(1, RasterStretchType.ESRI, 2, colorRamp);
        // Create a new stretch colorizer using the colorizer definition created above.
        CIMRasterStretchColorizer newStretchColorizer_custom =
          await isLayer.CreateColorizerAsync(stretchColorizerDef_custom) as CIMRasterStretchColorizer;
        // Set the new colorizer on the image service layer.
        isLayer.SetColorizer(newStretchColorizer_custom);
      }
    });
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Mapping.LayerDrawingDefinition
          ArcGIS.Desktop.Mapping.RasterColorizerDefinition
             ArcGIS.Desktop.Mapping.StretchColorizerDefinition

    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also