Howto: 如何在VBA中使用IBasicGeoprocessor对两个要素图层进行相交运算
文章编号 : 20667
软件: ArcGIS - ArcEditor 8.1, 8.1.2, 8.2, 8.3, 9.0, 9.1, 9.2, 9.3, 9.3.1 ArcGIS - ArcInfo 8.1, 8.1.2, 8.2, 8.3, 9.0, 9.1, 9.2, 9.3, 9.3.1 ArcGIS - ArcView 8.1, 8.1.2, 8.2, 8.3, 9.0, 9.1, 9.2, 9.3, 9.3.1
操作系统: Windows NT 4.0 ,2000 ,XP
软件: ArcGIS - ArcEditor 8.1, 8.1.2, 8.2, 8.3, 9.0, 9.1, 9.2, 9.3, 9.3.1 ArcGIS - ArcInfo 8.1, 8.1.2, 8.2, 8.3, 9.0, 9.1, 9.2, 9.3, 9.3.1 ArcGIS - ArcView 8.1, 8.1.2, 8.2, 8.3, 9.0, 9.1, 9.2, 9.3, 9.3.1
操作系统: Windows NT 4.0 ,2000 ,XP
1 个回复
易智瑞技术支持
赞同来自:
IBasicGeoprocessor包含五种方法:Dissolve, Merge, Clip, Intersect和union ,用户可在VB或VBA中调用这些方法。 Intersect方法根据覆盖图层的中多边形与输入图层中的线或面要素相交的多边形创建新的要素类。 输出要素类中包含所有输入要素图层的属性,且仅包含落入覆盖图层中多边形边界内的要素。
内容:
Intersect语法为: Set variable = object.Intersect(InputTable, useSelectedInput, overlayTable, useSelectedOverlay, Tolerance, outputName)
参数意义如下:
Variable-是对实现了IFeatureClass接口对象的一个引用。
Object-等同于IBasicGeoprocessor的对象。
InputTable-一个ITable对象。
useSelectedInput-一个布尔值,代表输入图层中的选中状态。用于指示是否只有输入图层中的选中要素参与相交运算,False代表相交操作将忽略输入图层中的选中子集。
overlayTable-一个对象。
useSelectedOverlay-是个布尔值,代表覆盖图层中的选中状态。用于指示在运算过程中是否使用图
层中的选中要素,False代表裁切操作将忽略覆盖图层中的选中子集。
Tolerance-代表容差的一个双精度值。是裁切过程中的容差,如果输入0.0则将使用系统默认值,数
据框架范围的10000分之一。
outputName-一个IFeatureClassName对象。
VBA中的示例如下:
Public Sub Intersect()
' Get the input layer and feature class.
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
Dim pLayer As ILayer
Set pLayer = pMxDoc.FocusMap.Layer(0)
Dim pInputFeatLayer As IFeatureLayer
Set pInputFeatLayer = player
' Use the Itable interface from the Layer (not from the FeatureClass)
Dim pInputTable As ITable
Set pInputTable = player
' Get the input feature class.
' The Input feature class properties, such as shape type,
' will be needed for the output.
Dim pInputFeatClass As IFeatureClass
Set pInputFeatClass = pInputFeatLayer.FeatureClass
' Get the overlay layer
' Use the Itable interface from the Layer (not from the FeatureClass)
Set pLayer = pMxDoc.FocusMap.Layer(1)
Dim pOverlayTable As ITable
Set pOverlayTable = pLayer
' Error checking
If pInputTable Is Nothing Then
MsgBox "Table QI failed"
Exit Sub
End If
If pOverlayTable Is Nothing Then
MsgBox "Table QI failed"
Exit Sub
End If
' Define the output feature class name and shape type (taken from the
' properties of the input feature class)
Dim pFeatClassName As IFeatureClassName
Set pFeatClassName = New FeatureClassName
With pFeatClassName
.FeatureType = esriFTSimple
.ShapeFieldName = "Shape"
.ShapeType = pInputFeatClass.ShapeType
End With
' Set output location and feature class name
Dim pNewWSName As IWorkspaceName
Set pNewWSName = New WorkspaceName
pNewWSName.WorkspaceFactoryProgID = "esriCore.ShapeFileWorkspaceFactory.1"
pNewWSName.PathName = "C:\temp"
Dim pDatasetName As IDatasetName
Set pDatasetName = pFeatClassName
pDatasetName.Name = "Intersect_result"
Set pDatasetName.WorkspaceName = pNewWSName
' Set the tolerance. Passing 0.0 causes the default tolerance to be used.
' The default tolerance is 1/10,000 of the extent of the data frame?s spatial domain
Dim tol As Double
tol = 0#
' Perform the intersect
Dim pBGP As IBasicGeoprocessor
Set pBGP = New BasicGeoprocessor
Dim pOutputFeatClass As IFeatureClass
Set pOutputFeatClass = pBGP.intersect(pInputTable, False, pOverlayTable, False, _
tol, pFeatClassName)
' Add the output layer to the map
Dim pOutputFeatLayer As IFeatureLayer
Set pOutputFeatLayer = New FeatureLayer
Set pOutputFeatLayer.FeatureClass = pOutputFeatClass
pOutputFeatLayer.Name = pOutputFeatClass.AliasName
pMxDoc.FocusMap.AddLayer pOutputFeatLayer
End Sub
创建时间:2001-10-10
最近更新: 2010-06-17
【原文链接】
http://support.esrichina.com.cn/2001/1010/754.html
要回复问题请先登录或注册