YouTube | Facebook | Twitter  Feed

ClassBreaksRenderer の利用

2016/9/1 (木)

Public Function GetColors(vbStartColor As Long, vbEndColor As Long, Colors As Long) As IEnumColors
  Dim pStartColor As IRgbColor
  Dim pEndColor As IRgbColor
 
  Set pStartColor = New RgbColor
  Set pEndColor = New RgbColor
   
  pStartColor.RGB = vbStartColor
  pEndColor.RGB = vbEndColor
   
  Dim pRamp As IAlgorithmicColorRamp
  Set pRamp = New AlgorithmicColorRamp
   
  pRamp.Algorithm = esriHSVAlgorithm
  pRamp.FromColor = pStartColor
  pRamp.ToColor = pEndColor
  pRamp.size = Colors
 
  Dim blnIsRampOK As Boolean
  pRamp.CreateRamp blnIsRampOK
  If Not blnIsRampOK Then Exit Function
 
  Set GetColors = pRamp.Colors
End Function
Public Sub ClassifyPop()
  Dim pMxDoc As IMxDocument
  Dim pGFLayer As IGeoFeatureLayer
   
  Set pMxDoc = ThisDocument
  Set pGFLayer = pMxDoc.FocusMap.Layer(2)
   
  Dim lngClasses As Long
  lngClasses = InputBox("人口をいくつにクラス分類しますか?")
  If lngClasses < 2 Then Exit Sub
   
  Dim arrBreaks() As Double
  arrBreaks = GetEqualIntervalBreaks(pGFLayer, "Pop1999", lngClasses)
   
  Dim pEnumColors As IEnumColors
  Set pEnumColors = GetColors(vbYellow, vbRed, lngClasses)
   
  Dim pClassBreaksRenderer As IClassBreaksRenderer
  Set pClassBreaksRenderer = New ClassBreaksRenderer
  pClassBreaksRenderer.Field = "Pop1999"
  pClassBreaksRenderer.BreakCount = lngClasses
  pClassBreaksRenderer.SortClassesAscending = True
   
  Dim pColor As IColor
  Dim pFillSymbol As ISimpleFillSymbol
   
  Dim intBreakIndex As Integer
  For intBreakIndex = 0 To lngClasses - 1
    Set pFillSymbol = New SimpleFillSymbol
    Set pColor = pEnumColors.Next
    pFillSymbol.Color = pColor
    pClassBreaksRenderer.Symbol(intBreakIndex) = pFillSymbol
    pClassBreaksRenderer.Break(intBreakIndex) = arrBreaks(intBreakIndex + 1)
  Next intBreakIndex
   
  Set pGFLayer.Renderer = pClassBreaksRenderer
  pMxDoc.UpdateContents
  pMxDoc.ActiveView.Refresh
End Sub

関連記事

  • この記事を書いた人

羽田 康祐

好きな地図投影法 はパース・クィンカンシャル図法とマクブライド・トーマス平極四次曲線図法。広島市出身。GIS上級技術者、Esri認定インストラクター、測量士補、潜水士、元PADIダイブマスター、四アマ。GIS を使った自己紹介はこちら。ESRIジャパン(株)所属、発言は個人の見解です。

-プログラミング, ArcGIS
-,

© 2021 WINGFIELD since1981