YouTube | Facebook | X(Twitter) | RSS

ラスター レイヤーから断面を作成

2016/9/1 (木)

Sub GetInterpolateShapeFromRaster()
    Dim pMxDocument As IMxDocument
    Set pMxDocument = ThisDocument
     
    Dim pRasterLayer As IRasterLayer
    Set pRasterLayer = pMxDocument.FocusMap.Layer(0)
     
    'Dim pRasterBandCollection As IRasterBandCollection
    'Set pRasterBandCollection = pRasterLayer.Raster
     
     
    Dim pRasterSurface As IRasterSurface
    Set pRasterSurface = New RasterSurface
    'pRasterSurface.RasterBand = pRasterBandCollection.Item(0)
    pRasterSurface.PutRaster pRasterLayer.Raster, 0 'Rasterからサーフェス用ラスタを取得
     
    Dim pSurface As ISurface
    Set pSurface = pRasterSurface
     
     
     
    Dim pEnumGeometry As IEnumGeometry
    Set pEnumGeometry = GetGraphicElements(pMxDocument.FocusMap)
     
    Dim pInputGeometry As IGeometry
    Set pInputGeometry = pEnumGeometry.Next
     
    Dim pInputCurve As ICurve
    Set pInputCurve = pInputGeometry
     
    Dim pInputCurve3D As ICurve3D
    Set pInputCurve3D = pInputGeometry
     
    Debug.Print "Input:", pInputCurve.Length
     
    Dim pOutGeometry As IGeometry
     
     
     
    Call pSurface.InterpolateShape(pInputGeometry, pOutGeometry)
     
    Dim pOutCurve3D As ICurve3D
    Set pOutCurve3D = pOutGeometry
     
    Debug.Print "Output:", pOutCurve3D.Length3D
 
End Sub
 
 
 
 
 
'グラフィックからすべてのジオメトリを取得
Public Function GetGraphicElements(GraphicsContainer As IGraphicsContainer) As IEnumGeometry
    GraphicsContainer.Reset
     
    Dim pElement As IElement
    Set pElement = GraphicsContainer.Next
     
    Dim pGeometryCollection As IGeometryCollection
    Set pGeometryCollection = New GeometryBag
     
    Do Until pElement Is Nothing
         
        pGeometryCollection.AddGeometry pElement.Geometry
         
        Set pElement = GraphicsContainer.Next
     
    Loop
     
    Set GetGraphicElements = pGeometryCollection
 
End Function
  • この記事を書いた人

羽田 康祐

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

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