用程序实现从带高程的点数据到等高线的转换

link: http://www.gisempire.com/blog/more.asp?name=gis&id=86

 

内容摘要 从高程点到等高线不是一步实现的,而是先把高程点先插值生成TIN,然后再从TIN生成等高线。在从TIN到等高线的生成过程中8.3和9.0上还有点区别,请看代码注释。下面的是整个过程的代码实例。 过程描述 '打开高程点数据
Dim pFeatureLayer As IFeatureLayer
Set pFeatureLayer = MapControl1.Map.Layer(0)
If pFeatureLayer Is Nothing Then Exit Sub
Dim pFeatureClass As IFeatureClass
Set pFeatureClass = pFeatureLayer.FeatureClass

'生成TIN
Dim pTinEdit As ITinEdit
Dim pTinSurface As ISurface
Dim pTable As ITable
Set pTinEdit = New Tin
Set pTable = New FeatureLayer
pTinEdit.InitNew MapControl1.ActiveView.Extent
Dim pField As IField
Set pField = pFeatureClass.Fields.Field(pFeatureClass.Fields.FindField("Well_Dpth"))
pTinEdit.AddFromFeatureClass pFeatureClass, Nothing, pField, Nothing, 18

Set pTinSurface = pTinEdit

'打开已经创建好的空的等高线数据(也可以在此时创建一个要素类9,如果是9.0版本的话,在空等高线数据中预先需要建一个字段来存储高
'程值,如果是8.3版本的话就不可以预先创建这样的一个高程字段,而是在生成等高线过程中根据你指定的
'字段名称实时创建
Dim pPropset As IPropertySet
Set pPropset = New PropertySet

Dim pFact As IWorkspaceFactory
Dim pWorkspace As IWorkspace

pPropset.SetProperty "DATABASE", App.Path + "\data\"

Set pFact = New ShapefileWorkspaceFactory
Set pWorkspace = pFact.Open(pPropset, Me.hWnd)

Dim pFeatureWorkspace As IFeatureWorkspace
Set pFeatureWorkspace = pWorkspace

Dim pFeatureClass1 As IFeatureClass
Set pFeatureClass1 = pFeatureWorkspace.OpenFeatureClass("MyShape33")

'生成等高线
pTinSurface.Contour 0, 50, pFeatureClass1, "Well_Dpth", 1

Dim pFLayer As IFeatureLayer
Set pFLayer = New FeatureLayer
Set pFLayer.FeatureClass = pFeatureClass1

MapControl1.AddLayer pFLayer
MapControl1.ActiveView.Refresh

你可能感兴趣的:(转换)