YouTube | Facebook | X(Twitter) | RSS

ラスター レイヤーの数値分類

2016/9/1 (木)

ラスタの数値分類で設定する閾値はIRasterClassifyColorRampRenderer::Breakを使用する。閾値の範囲の下側の値を設定する。

.NET http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/d/000100000267000000.htm

Sub UsingRasterClassifyColorRampRenderer()
    'Get Map
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
    Dim pMap As IMap
    Set pMap = pMxDoc.FocusMap
     
    'Get raster input from layer
    Dim pRLayer As IRasterLayer
    Set pRLayer = pMap.Layer(0)
    Dim pRaster As IRaster
    Set pRaster = pRLayer.Raster
     
    'Create classfy renderer and QI RasterRenderer interface
    Dim pClassRen As IRasterClassifyColorRampRenderer
    Set pClassRen = New RasterClassifyColorRampRenderer
    Dim pRasRen As IRasterRenderer
    Set pRasRen = pClassRen
     
    'Set raster for the render and update
    Set pRasRen.Raster = pRaster
    pClassRen.ClassCount = 3
    pRasRen.Update
     
    'Create a color ramp to use
    Dim pRamp As IAlgorithmicColorRamp
    Set pRamp = New AlgorithmicColorRamp
    pRamp.size = 3
    pRamp.CreateRamp True
     
    'Create symbol for the classes
    Dim pFSymbol As IFillSymbol
    Set pFSymbol = New SimpleFillSymbol
     
    'loop through the classes and apply the color and label
    Dim I As Integer
    For I = 0 To pClassRen.ClassCount - 1
        pFSymbol.Color = pRamp.Color(I)
        pClassRen.Symbol(I) = pFSymbol
        pClassRen.Label(I) = "Class" & CStr(I)
    Next I
     
    Dim pColor As IColor
    Set pColor = New RgbColor
    pColor.NullColor = True
     
    pFSymbol.Color = pColor
    pClassRen.Symbol(0) = pFSymbol
     
    pClassRen.Break(0) = -57
    pClassRen.Break(1) = 0
    pClassRen.Break(2) = 39
     
    'Update the renderer and plug into layer
    pRasRen.Update
    Set pRLayer.Renderer = pClassRen
    pMxDoc.ActiveView.Refresh
    pMxDoc.UpdateContents
     
    'Release memeory
    Set pMxDoc = Nothing
    Set pMap = Nothing
    Set pRLayer = Nothing
    Set pRaster = Nothing
    Set pRasRen = Nothing
    Set pClassRen = Nothing
    Set pRamp = Nothing
    Set pFSymbol = Nothing
End Sub
  • この記事を書いた人

羽田 康祐

伊達と酔狂のGISエンジニア。GIS上級技術者、Esri認定インストラクター、CompTIA CTT+ Classroom Trainer、潜水士、PADIダイブマスター、四アマ。WordPress は 2.1 からのユーザーで歴だけは長い。 代表著書『"地図リテラシー入門―地図の正しい読み方・描き方がわかる』 GIS を使った自己紹介はこちら。ESRIジャパン(株)所属、元青山学院大学非常勤講師を兼務。日本地図学会第31期常任委員。発言は個人の見解です。

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