ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / DotDensityRendererDefinition Class
Members Example

In This Topic
    DotDensityRendererDefinition Class
    In This Topic
    Represents a dot density symbol renderer definition to show quantitative values for a field as a series of pattern fills based on the field value for each polygon.
    Object Model
    DotDensityRendererDefinition ClassCIMSymbolReference ClassCIMColorRamp Class
    Syntax
    Public Class DotDensityRendererDefinition 
       Inherits RendererDefinition
    public class DotDensityRendererDefinition : RendererDefinition 
    Remarks
    With dot density symbology, the data you symbolize is not classified. Instead, quantitative values for one or more fields are represented as a collection of point symbols (typically solid circles or dots) within each polygon. Each dot represents a constant number of things, or people, or other quantifiable phenomena. The dots are equally sized, even when multiple fields are symbolized together within a layer.
    Example
    Dot Density renderer.
    /// <summary>
    /// Renders a polygon feature layer with Dot Density symbols to represent quantities.
    /// ![Dot Density renderer](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/dotDensity-renderer.png)
    /// </summary>
    {
      //Check feature layer name
      //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics");
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
      }
      //Define size of the dot to use for the renderer
      int dotSize = 3;
      //Check if the TOTPOP10 field exists
      int idxField = -1;
      using (var table = featureLayer.GetTable())
      {
        var def = table.GetDefinition();
        idxField = def.FindField("TOTPOP10");
      }
      // "TOTPOP10" field was not found
      if (idxField == -1)
        return;
    
      //array of fields to be represented in the renderer
      var valueFields = new List<string> { "TOTPOP10" };
      //Note: Run within QueuedTask
      //Create the DotDensityRendererDefinition object
      var dotDensityDef = new DotDensityRendererDefinition(valueFields, colorRamp,
                                                                        dotSize, 30000, "Dot", "people");
      //Create the renderer using the DotDensityRendererDefinition
      CIMDotDensityRenderer dotDensityRndr = (CIMDotDensityRenderer)featureLayer.CreateRenderer(dotDensityDef);
    
      //if you want to customize the dot symbol for the renderer, create a "DotDensitySymbol" which is an
      //Amalgamation of 3 symbol layers: CIMVectorMarker, CIMSolidFill and CIMSolidStroke
      //Define CIMVectorMarker layer          
      var cimMarker = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, dotSize);
      var dotDensityMarker = cimMarker as CIMVectorMarker;
      //Define the placement
      CIMMarkerPlacementInsidePolygon markerPlacement = new CIMMarkerPlacementInsidePolygon { Randomness = 100, GridType = PlacementGridType.RandomFixedQuantity, Clipping = PlacementClip.RemoveIfCenterOutsideBoundary };
      dotDensityMarker.MarkerPlacement = markerPlacement;
    
      //Define CIMSolidFill layer
      CIMSolidFill solidFill = new CIMSolidFill { Color = new CIMRGBColor { R = 249, G = 232, B = 189, Alpha = 50 } };
    
      //Define CIMSolidStroke
      CIMSolidStroke solidStroke = new CIMSolidStroke { Color = ColorFactory.Instance.GreyRGB, Width = .5 };
    
      //Create the amalgamated CIMPolygonSymbol that includes the 3 layers
      var dotDensitySymbol = new CIMPolygonSymbol
      {
        SymbolLayers = new CIMSymbolLayer[] { dotDensityMarker, solidFill, solidStroke }
      };
    
      //Apply the dotDensitySymbol to the CIMDotDenstityRenderer's DotDensitySymbol property.
      dotDensityRndr.DotDensitySymbol = dotDensitySymbol.MakeSymbolReference();
    
      //Apply the renderer to the polygon Feature Layer.
      featureLayer.SetRenderer(dotDensityRndr);
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Mapping.LayerDrawingDefinition
          ArcGIS.Desktop.Mapping.RendererDefinition
             ArcGIS.Desktop.Mapping.DotDensityRendererDefinition

    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also