Bivariate Renderers



Description:

This sample consists of two custom bivariate renderers: ColorBivariateRend and ColorSzBivariateRend. In general, bivariate renderers are useful for representing the relationship between two data distributions. Two variables are classified independently, and their combination is represented using some combination of symbol color and size.

The first renderer, ColorBivariateRend, combines two graduated color representations. On this renderer, symbol colors from the constituent representations are blended to produce the resultant symbology. The second renderer, ColorSzBivariateRend, combines a graduated color representation and a graduated symbol representation. On this renderer, the symbol color is taken from one representation, while symbol size is taken from the other representation to produce the resultant symbology. Each bivariate renderer is built from two ClassBreaksRenderers, and both implement ESRI's IBivariateRenderer interface. ColorBivariateRend also implements a custom interface, IColorBivariateRend.

The sample code for each renderer demonstrates how to design a feature renderer to draw custom layer symbology. IFeatureRenderer::SymbolByFeature is also demonstrated by both sets of code. ColorSzBivariateRenderer shows how to draw symbology in both the Geography and Annotation draw phases. This renderer also employs a strategy to draw symbols in order from large to small so that smaller features will appear on top.

Notes:

The TOC entry for ColorSzBivariateRenderer is not editable (same behavior as ESRI's BiUniqueValueRenderer)

IColorBivariateRend::ColorCombinationMethod controls how colors are blended in the ColorBivariateRenderer. There are three options: CIELAb, LabLCh, and RGBAverage. The first two options employ an ESRI AlgorithmicColorRamp object to interpolate a color halfway between the two colors in the applicable color space. The RGBAverage method averages the R,G, and B for the two colors. This method may yield darker than desirable merged colors with some color combinations.
Products:
ArcView: VB6

Platforms: Windows, Solaris

Requires: For VB Usage: An ArcMap session with the same layer added three times.

Minimum ArcGIS Release: 9.0

How to use:
[VB]
  1. Register this sample's dll by compiling the sample or by using Regsvr32.exe.
  2. Start ArcMap.
  3. In the Visual Basic Editor, go to Tools > References. If this sample's dll does not appear in the Available References box, browse to the dll and add it. Check the box next to the dll's name. Dismiss the References dialog.
  4. Copy-paste the following subroutines into a code module.
    
    Public Sub ApplyColorBivariateRend()
    
    ' December 2, 2000
    ' ESRI ArcMap Development
    
    ' creates a new ColorBivariateRend
    ' sets MainRenderer equal to renderer from 1st layer
    ' sets VariationRenderer equal to renderer from 2nd layer
    ' assigns new renderer to 3rd layer
           
        Dim pMxDoc As IMxDocument
        Dim pFeatLayer As IGeoFeatureLayer
        Dim pFeatClass As IFeatureClass
        Dim pColorRend As IClassBreaksRenderer
        Dim pColorRend2 As IClassBreaksRenderer
        Dim i As Integer
        Dim pBivariateRend As IBivariateRenderer
        Dim pTwoWayColorRend As IColorBivariateRend
        Dim pFeatRend As IFeatureRenderer
        Dim bOK As Boolean
                
        Set pMxDoc = Application.Document
        Set pFeatLayer = pMxDoc.ActiveView.FocusMap.Layer(0)
        Set pColorRend = pFeatLayer.Renderer
        Set pFeatLayer = pMxDoc.ActiveView.FocusMap.Layer(1)
        Set pColorRend2 = pFeatLayer.Renderer
    
        Set pBivariateRend = New BivariateRenderers.ColorBivariateRend
        Set pBivariateRend.MainRenderer = pColorRend
        Set pBivariateRend.VariationRenderer = pColorRend2
        Set pTwoWayColorRend = pBivariateRend
        pTwoWayColorRend.ColorCombinationMethod = enuCIELabColorRamp
        
        pBivariateRend.CreateLegend
    
        Set pFeatLayer = pMxDoc.ActiveView.FocusMap.Layer(2)
        Set pFeatRend = pBivariateRend
    
        Set pFeatLayer.Renderer = pBivariateRend
        pMxDoc.UpdateContents
        pMxDoc.ActiveView.Refresh
    End Sub
    
    
    Public Sub ApplyColorSzBivariateRend()
    
    ' October 24, 2000
    ' ESRI ArcMap Development
    
    ' creates a new ColorSzBivariateRend
    ' sets MainRenderer equal to renderer from 1st layer (graduated colors)
    ' sets VariationRenderer equal to renderer from 2nd layer (graduated symbols)
    ' assigns new renderer to 3rd layer
           
        Dim pMxDoc As IMxDocument
        Dim pFeatLayer As IGeoFeatureLayer
        Dim pFeatClass As IFeatureClass
        Dim pColorRend As IClassBreaksRenderer
        Dim pColorRend2 As IClassBreaksRenderer
        Dim i As Integer
        Dim pBivariateRend As IBivariateRenderer
        Dim pFeatRend As IFeatureRenderer
        Dim bOK As Boolean
                
        Set pMxDoc = Application.Document
        Set pFeatLayer = pMxDoc.ActiveView.FocusMap.Layer(0)
        Set pColorRend = pFeatLayer.Renderer
        Set pFeatLayer = pMxDoc.ActiveView.FocusMap.Layer(1)
        Set pColorRend2 = pFeatLayer.Renderer
    
        Set pBivariateRend = New BivariateRenderers.ColorSzBivariateRend
        Set pBivariateRend.MainRenderer = pColorRend
        Set pBivariateRend.VariationRenderer = pColorRend2
        
        Set pFeatLayer = pMxDoc.ActiveView.FocusMap.Layer(2)
        Set pFeatRend = pBivariateRend
    
        Set pFeatLayer.Renderer = pBivariateRend
        pMxDoc.UpdateContents
        pMxDoc.ActiveView.Refresh
    End Sub
            
  5. Add a dataset to ArcMap that you wish to draw with one of the bivariate renderers.
  6. Copy and paste the layer twice so that you have three copies of the layer in your map document.
  7. Set up graduated color symbology on the first layer using the Symbology tab of the Layer Properties dialog box.
  8. If you intend to use the ColorBivariateRend, set up graduated color symbology on the second layer as well. If you intend to use the ColorSzBivariateRend, set up graduated symbol symbology on the second layer.
  9. Uncheck the visibity check box for the first two layers in the TOC. Finally, run the applicable macro (Tools --> Macros --> Run) to apply bivariate symbology to the third map layer.

Download the VB6 files
IColorBivariateRenderer.cls Custom interface class.
ColorBivariateRenderer.cls CoClass for the two way color bivariate renderer.
ColorSizeBivariateRenderer.cls CoClass for the color-size bivariate renderer.
BivariateRenderers.vbp Visual Basic project file.
BivariateRenderers.dll The compiled component.

Download the files for all languages



Key Libraries: Carto
Key CoClasses:ClassBreaksRenderer, LegendGroup, LegendClass
Key Interfaces: IFeatureRenderer, IBivariateRenderer, IClassBreaksRenderer, IFeatureRenderer, ILegendGroup, IAlgorithmicColorRamp
Key Members: IFeatureRenderer::SymbolByFeature