已经困惑很久的问题(TinToRaster数据转换),请高手指点,不胜感激!
'***************************************
'*目的:Tin To Raster数据转换
'*输入:Tin数据
'*输出:Raster数据
'*日期:xxb/06/04/13
'***************************************
Imports ESRI.ArcGIS.Analyst3D
Imports ESRI.ArcGIS.SceneControl
Imports ESRI.ArcGIS.Geodatabase
Imports ESRI.ArcGIS.DataSourcesFile
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.DataSourcesRaster
Imports ESRI.ArcGIS.Geometry
Imports ESRI.ArcGIS.esriSystem
Imports ESRI.ArcGIS.Display
Imports ESRI.ArcGIS.Framework
Imports stdole
Public Class Form1
Inherits System.Windows.Forms.Form
Private pGDS As IGeoDataset
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents AxSceneControl1 As AxesriSceneControl.AxSceneControl
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.Button1 = New System.Windows.Forms.Button
Me.AxSceneControl1 = New AxesriSceneControl.AxSceneControl
CType(Me.AxSceneControl1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(136, 8)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(280, 24)
Me.Button1.TabIndex = 0
Me.Button1.Text = "TinToRaster"
'
'AxSceneControl1
'
Me.AxSceneControl1.Location = New System.Drawing.Point(8, 40)
Me.AxSceneControl1.Name = "AxSceneControl1"
Me.AxSceneControl1.OcxState = CType(resources.GetObject("AxSceneControl1.OcxState"), System.Windows.Forms.AxHost.State)
Me.AxSceneControl1.Size = New System.Drawing.Size(544, 368)
Me.AxSceneControl1.TabIndex = 1
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(560, 414)
Me.Controls.Add(Me.AxSceneControl1)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.AxSceneControl1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'***************************************
'*目的:加载Tin类型地表数据
'***************************************
Dim pWorkspaceFactory As IWorkspaceFactory
Dim pWorkspace As ITinWorkspace
pWorkspaceFactory = New TinWorkspaceFactory
pWorkspace = pWorkspaceFactory.OpenFromFile("F:\GisTestEnvi\DataSource\Data\Terraindata", 0)
'***************************************************************
'*目的:判断一个地表数据是不是tin,定义TinToRaster()函数的tin数据
'***************************************************************
Dim pTin As ITinAdvanced
If pWorkspace.IsTin("tin1") Then
pTin = pWorkspace.OpenTin("tin1")
End If
'定义TinToRaster()函数参数pExtent
pGDS = pTin
Dim pExtent As IEnvelope
pExtent = pGDS.Extent
'定义TinToRaster()函数参数eMethod
Dim eMethod As esriRasterizationType
eMethod = esriRasterizationType.esriDegreeAspectAsRaster
'定义TinToRaster()函数参数sDir,sName,cellsize
Dim sDir As String = "F:\GisTestEnvi\DataAim"
Dim sName As String = "data"
Dim cellsize As Double = 8.42
Dim pRDS As IRasterDataset
pRDS = TinToRaster(pTin, eMethod, sDir, sName, rstPixelType.PT_FLOAT, cellsize, pExtent, True)
MsgBox("ok")
'***************************************************************
'*目的:添加Raster数据到Arcsence控件上
'***************************************************************
Dim pSgraph As ISceneGraph
Dim pScene As IScene
pScene = AxSceneControl1.Scene
pSgraph = pScene.SceneGraph
' 打开Raster数据集取得Raster数据
Dim raster As IRaster = pRDS.CreateDefaultRaster()
' 添加Raster数据到Raster层上
Dim pRasterLayer As IRasterLayer
pRasterLayer = New RasterLayerClass
pRasterLayer.CreateFromRaster(raster)
' 不是Raster数据就返回
If pRasterLayer Is Nothing Then
Return
End If
pScene.ClearLayers()
pScene.AddLayer(pRasterLayer, True) '显示
End Sub