YouTube | Facebook | Twitter  Feed

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

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

関連記事

  • この記事を書いた人

羽田 康祐

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

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