AE开发中,矢量图层叠加分析需要用到的主要类为BasicGeoprocessor,其主要接口为IBasicGeoprocessorIBasicGeoprocessor接口提供了基本的空间数据处理的方法和属性,其中包括叠加求交(Interset)和叠加求和(Union)

下面提供两个叠加求交的开发实例:

一、  VB+AE9.1叠加求交示例代码:

 

 1矢量图层叠加求交分析Private Sub M_OverLayer_Click()
 2矢量图层叠加求交分析' Get the input layer and feature class
 3矢量图层叠加求交分析  Dim pLayer As ILayer
 4矢量图层叠加求交分析  Set pLayer = MapControl1.Layer(0)
 5矢量图层叠加求交分析  Dim pInputFeatLayer As IFeatureLayer
 6矢量图层叠加求交分析  Set pInputFeatLayer = pLayer
 7矢量图层叠加求交分析  ' Use the Itable interface from the Layer (not from the FeatureClass)
 8矢量图层叠加求交分析  
 9矢量图层叠加求交分析  Dim pInputTable As ITable
10矢量图层叠加求交分析  Set pInputTable = pLayer
11矢量图层叠加求交分析  ' Get the input feature class.
12矢量图层叠加求交分析  ' The Input feature class properties, such as shape type,
13矢量图层叠加求交分析  ' will be needed for the output
14矢量图层叠加求交分析  
15矢量图层叠加求交分析  Dim pInputFeatClass As IFeatureClass
16矢量图层叠加求交分析  Set pInputFeatClass = pInputFeatLayer.FeatureClass
17矢量图层叠加求交分析  ' Get the overlay layer
18矢量图层叠加求交分析  ' Use the Itable interface from the Layer (not from the FeatureClass)
19矢量图层叠加求交分析  Set pLayer = MapControl1.Layer(1)
20矢量图层叠加求交分析  Dim pOverlayTable As ITable
21矢量图层叠加求交分析  Set pOverlayTable = pLayer
22矢量图层叠加求交分析  
23矢量图层叠加求交分析  ' Error checking
24矢量图层叠加求交分析  If pInputTable Is Nothing Then
25矢量图层叠加求交分析    MsgBox "Table QI failed"
26矢量图层叠加求交分析    Exit Sub
27矢量图层叠加求交分析  End If
28矢量图层叠加求交分析  
29矢量图层叠加求交分析  If pOverlayTable Is Nothing Then
30矢量图层叠加求交分析    MsgBox "Table QI failed"
31矢量图层叠加求交分析    Exit Sub
32矢量图层叠加求交分析  End If
33矢量图层叠加求交分析  
34矢量图层叠加求交分析  ' Define the output feature class name and shape type (taken from the
35矢量图层叠加求交分析  ' properties of the input feature class)
36矢量图层叠加求交分析  Dim pFeatClassName As IFeatureClassName
37矢量图层叠加求交分析  Set pFeatClassName = New FeatureClassName
38矢量图层叠加求交分析  With pFeatClassName
39矢量图层叠加求交分析    .FeatureType = esriFTSimple
40矢量图层叠加求交分析    .ShapeFieldName = "Shape"
41矢量图层叠加求交分析    .ShapeType = pInputFeatClass.ShapeType
42矢量图层叠加求交分析  End With
43矢量图层叠加求交分析  
44矢量图层叠加求交分析  ' Set output location and feature class name
45矢量图层叠加求交分析  Dim pNewWSName As IWorkspaceName
46矢量图层叠加求交分析  Set pNewWSName = New WorkspaceName
47矢量图层叠加求交分析  pNewWSName.WorkspaceFactoryProgID = "esriCore.ShapeFileWorkspaceFactory.1"
48矢量图层叠加求交分析  pNewWSName.PathName = "C:\temp"
49矢量图层叠加求交分析  
50矢量图层叠加求交分析  Dim pDatasetName As IDatasetName
51矢量图层叠加求交分析  Set pDatasetName = pFeatClassName
52矢量图层叠加求交分析  pDatasetName.Name = "Intersect_result"
53矢量图层叠加求交分析  Set pDatasetName.WorkspaceName = pNewWSName
54矢量图层叠加求交分析  ' Set the tolerance. Passing 0.0 causes the default tolerance to be used.
55矢量图层叠加求交分析  ' The default tolerance is 1/10,000 of the extent of the data frame's spatial domain
56矢量图层叠加求交分析  
57矢量图层叠加求交分析  Dim tol As Double
58矢量图层叠加求交分析  tol = 0#      ' Perform the intersect
59矢量图层叠加求交分析  Dim pBGP As IBasicGeoprocessor
60矢量图层叠加求交分析  Set pBGP = New BasicGeoprocessor
61矢量图层叠加求交分析  
62矢量图层叠加求交分析  Dim pOutputFeatClass As IFeatureClass
63矢量图层叠加求交分析  Set pOutputFeatClass = pBGP.Intersect(pInputTable, False, pOverlayTable, False, _
64矢量图层叠加求交分析    tol, pFeatClassName)
65矢量图层叠加求交分析    
66矢量图层叠加求交分析  ' Add the output layer to the map
67矢量图层叠加求交分析  Dim pOutputFeatLayer As IFeatureLayer
68矢量图层叠加求交分析  Set pOutputFeatLayer = New FeatureLayer
69矢量图层叠加求交分析  Set pOutputFeatLayer.FeatureClass = pOutputFeatClass
70矢量图层叠加求交分析  pOutputFeatLayer.Name = pOutputFeatClass.AliasName
71矢量图层叠加求交分析  MapControl1.AddLayer pOutputFeatLayer
72矢量图层叠加求交分析End Sub
73矢量图层叠加求交分析
74矢量图层叠加求交分析
75矢量图层叠加求交分析

二、C#+AE9.1叠加求交示例代码:

 1矢量图层叠加求交分析        private void M_OverLayer_Click(object sender, System.EventArgs e)
 2        }

相关文章: