FAQ
ドット密度レンダラーでの表示

ナレッジ番号:5280 | 登録日:2023/07/26 | 更新日:2023/12/28

概要

ドット密度レンダラーは、ポリゴンの数値属性に基づきシンボルの内部にドットを表示するためのレンダラーです。このサンプル コードは、ドット密度レンダラーを作成する方法を示しています。

ImageImage

サンプル コード

ドット密度レンダラーの作成

このサンプル コードでは、"population" フィールドを利用して、ドット サイズ 3、ドット値 300 でドット密度レンダラを作成しています。レンダリングの対象となるレイヤはマップの最上位にあるものとします。

    IMxDocument pMxDoc = ArcMap.Application.Document as IMxDocument;
    IGeoFeatureLayer glay = pMxDoc.FocusMap.get_Layer(0) as IGeoFeatureLayer;
    DotDensityRenderer(glay);

private void DotdensityRenderer(ref IGeoFeatureLayer pGeoFeatureLayer)   
{
    //レンダラーを作成する。
    IDotDensityRenderer pDotDensityRenderer = new DotDensityRendererClass();
    //マーカー シンボルを作成する。
    ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();

    //'塗りつぶしシンボルの色を作成する。
    IRgbColor pRGBColor = new RgbColorClass();
    pRGBColor.Red = 225;
    pRGBColor.Green = 84;
    pRGBColor.Blue = 30;

    //マーカーのスタイルは、サークル型とする。
    pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
    //シンボルに色を適用する。
    pSimpleMarkerSymbol.Color = pRGBColor;

    //レンダラーに作成したシンボルを適用する。
    //IChartRenderer pchartren = PieChartRenderer as IChartRenderer;
    IDotDensityFillSymbol pDotDensityFillSymbol = new DotDensityFillSymbolClass();
    IRendererFields prenf = pDotDensityRenderer as IRendererFields;
    prenf.AddField("population"); 
    ISymbolArray psymarray = pDotDensityFillSymbol as ISymbolArray;
    psymarray.AddSymbol(pSimpleMarkerSymbol as ISymbol);
    pDotDensityFillSymbol.DotSize = 3;
    pDotDensityRenderer.DotDensitySymbol = pDotDensityFillSymbol;
    pDotDensityRenderer.DotValue = 300; 
    pDotDensityRenderer.CreateLegend();

    //'レイヤー(GeoFeatureLayer)にレンダラー(SimpleRenderer)を適用する。
    pGeoFeatureLayer.Renderer = pDotDensityRenderer as IFeatureRenderer;

    (ArcMap.Document as IMxDocument).UpdateContents();
    (ArcMap.Document.FocusMap as IActiveView).Refresh();
}
    Dim pMxDoc As IMxDocument = CType(My.ArcMap.Application.Document, IMxDocument)
    Dim glay As IGeoFeatureLayer = CType(pMxDoc.FocusMap.get_Layer(0), IGeoFeatureLayer)
    DotDensityRenderer(glay)

Public Sub DotDensityRenderer(pGeoFeatureLayer As IGeoFeatureLayer)
    'レンダラーを作成する。
    Dim pDotDensityRenderer As IDotDensityRenderer = New DotDensityRendererClass()
    'マーカーシンボルを作成する。
    Dim pSimpleMarkerSymbol As ISimpleMarkerSymbol = New SimpleMarkerSymbolClass()

    '塗りつぶしシンボルの色を作成する。
    Dim pRGBColor As IRgbColor = New RgbColorClass()
    pRGBColor.Red = 225
    pRGBColor.Green = 84
    pRGBColor.Blue = 30

    'マーカーのスタイルは、サークル型とする。
    pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle
    'シンボルに色を適用する。
    pSimpleMarkerSymbol.Color = pRGBColor

    'レンダラーに作成したシンボルを適用する。            
    Dim pDotDensityFillSymbol As IDotDensityFillSymbol = New DotDensityFillSymbolClass()
    Dim prenf As IRendererFields = CType(pDotDensityRenderer, IRendererFields)
    prenf.AddField("population")
    Dim psymarray As ISymbolArray = CType(pDotDensityFillSymbol, ISymbolArray)
    psymarray.AddSymbol(CType(pSimpleMarkerSymbol, ISymbol))
    pDotDensityFillSymbol.DotSize = 3
    pDotDensityRenderer.DotDensitySymbol = pDotDensityFillSymbol
    pDotDensityRenderer.DotValue = 300
    pDotDensityRenderer.CreateLegend()

    'レイヤー(GeoFeatureLayer) にレンダラー(SimpleRenderer)を適用する。
    pGeoFeatureLayer.Renderer = CType(pDotDensityRenderer, IFeatureRenderer)

    CType(My.ArcMap.Document, IMxDocument).UpdateContents()
    CType(My.ArcMap.Document, IMxDocument).Refresh()
End Sub

メタデータ

種類

製品