AE开发中,矢量图层叠加分析需要用到的主要类为BasicGeoprocessor,其主要接口为IBasicGeoprocessor。IBasicGeoprocessor接口提供了基本的空间数据处理的方法和属性,其中包括叠加求交(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![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
74![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
75
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
10
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
14
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
15
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
16
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
17
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
18
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
19
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
20
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
21
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
22
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
23
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
24
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
25
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
26
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
27
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
28
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
29
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
30
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
31
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
32
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
33
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
34
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
35
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
36
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
37
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
38
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
39
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
40
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
41
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
42
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
43
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
44
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
45
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
46
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
47
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
48
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
49
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
50
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
51
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
52
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
53
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
54
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
55
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
56
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
57
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
58
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
59
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
60
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
61
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
62
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
63
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
64
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
65
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
66
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
67
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
68
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
69
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
70
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
71
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
72
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
73
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
74
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
75
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
二、C#+AE9.1叠加求交示例代码:
1
private
void
M_OverLayer_Click(
object
sender, System.EventArgs e)
2![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
3
try
4![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
5
//分析层
6
ILayer pLayer=this.axMapControl1.get_Layer(0);
7
IFeatureLayer pInputFeatLayer=pLayer as IFeatureLayer;
8
ITable pInputTable=pLayer as ITable;
9
IFeatureClass pInputFeatClass=pInputFeatLayer.FeatureClass;
10![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
11
//叠加表
12
pLayer=this.axMapControl1.get_Layer(1);
13
ITable pOverlayTable=pLayer as ITable;
14![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
15
//叠加分析表
16
IFeatureClassName pFeatClassName=new FeatureClassNameClass();
17
pFeatClassName.FeatureType=esriFeatureType.esriFTSimple;
18
pFeatClassName.ShapeFieldName="shape";
19
pFeatClassName.ShapeType=pInputFeatClass.ShapeType;
20![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
//工作空间名称
22
IWorkspaceName pNewWSName=new WorkspaceNameClass();
23
pNewWSName.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory";
24
pNewWSName.PathName = @"C:\temp";
25![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
26
//数据集名称
27
IDatasetName pDatasetName=pFeatClassName as IDatasetName;
28
pDatasetName.Name="ss";
29
pDatasetName.WorkspaceName=pNewWSName;
30![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
31
//几何处理
32
IBasicGeoprocessor pBGP=new BasicGeoprocessorClass();
33
IFeatureClass pOutputFeatClass=pBGP.Intersect(pInputTable,false,pOverlayTable,false,0.01,pFeatClassName);
34
35
//输出要素层设置
36
IFeatureLayer pOutputFeatLayer=new FeatureLayerClass();
37
pOutputFeatLayer.FeatureClass=pOutputFeatClass;
38
pOutputFeatLayer.Name=pOutputFeatClass.AliasName;
39![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
40
this.axMapControl1.AddLayer((ILayer)pOutputFeatClass,0);
41
axMapControl1.Update();
42
}
43
catch(Exception ex)
44![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
45
MessageBox.Show(ex.Message);
46
}
47
}
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
3
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
4
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
5
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
6
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
8
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
9
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
10
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
11
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
12
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
13
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
14
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
15
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
16
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
17
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
18
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
20
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
22
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
23
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
24
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
25
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
26
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
27
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
28
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
29
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
30
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
31
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
32
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
33
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
34
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
35
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
36
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
37
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
38
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
39
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
40
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
41
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
42
![ExpandedSubBlockEnd.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
43
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
44
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
45
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
46
![ExpandedSubBlockEnd.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
47
![ExpandedBlockEnd.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)