矢量图层叠加求交分析

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

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

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

 

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

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

 1 None.gif          private   void  M_OverLayer_Click( object  sender, System.EventArgs e)
 2 ExpandedBlockStart.gifContractedBlock.gif         dot.gif {
 3InBlock.gif            try
 4ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 5InBlock.gif                //分析层
 6InBlock.gif                ILayer pLayer=this.axMapControl1.get_Layer(0);
 7InBlock.gif                IFeatureLayer pInputFeatLayer=pLayer as IFeatureLayer;    
 8InBlock.gif                ITable pInputTable=pLayer as ITable;
 9InBlock.gif                IFeatureClass pInputFeatClass=pInputFeatLayer.FeatureClass;
10InBlock.gif
11InBlock.gif                //叠加表
12InBlock.gif                pLayer=this.axMapControl1.get_Layer(1);
13InBlock.gif                ITable pOverlayTable=pLayer as ITable;
14InBlock.gif
15InBlock.gif                //叠加分析表
16InBlock.gif                IFeatureClassName pFeatClassName=new FeatureClassNameClass();
17InBlock.gif                pFeatClassName.FeatureType=esriFeatureType.esriFTSimple;
18InBlock.gif                pFeatClassName.ShapeFieldName="shape";
19InBlock.gif                pFeatClassName.ShapeType=pInputFeatClass.ShapeType;
20InBlock.gif
21InBlock.gif                //工作空间名称
22InBlock.gif                IWorkspaceName pNewWSName=new WorkspaceNameClass();
23InBlock.gif                pNewWSName.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory";
24InBlock.gif                pNewWSName.PathName = @"C:\temp";
25InBlock.gif
26InBlock.gif                //数据集名称
27InBlock.gif                IDatasetName pDatasetName=pFeatClassName as IDatasetName;
28InBlock.gif                pDatasetName.Name="ss";
29InBlock.gif                pDatasetName.WorkspaceName=pNewWSName; 
30InBlock.gif
31InBlock.gif                //几何处理
32InBlock.gif                IBasicGeoprocessor pBGP=new BasicGeoprocessorClass();
33InBlock.gif                IFeatureClass pOutputFeatClass=pBGP.Intersect(pInputTable,false,pOverlayTable,false,0.01,pFeatClassName);  
34InBlock.gif   
35InBlock.gif                //输出要素层设置
36InBlock.gif                IFeatureLayer pOutputFeatLayer=new FeatureLayerClass();
37InBlock.gif                pOutputFeatLayer.FeatureClass=pOutputFeatClass;
38InBlock.gif                pOutputFeatLayer.Name=pOutputFeatClass.AliasName;
39InBlock.gif
40InBlock.gif                this.axMapControl1.AddLayer((ILayer)pOutputFeatClass,0);
41InBlock.gif                axMapControl1.Update();
42ExpandedSubBlockEnd.gif            }

43InBlock.gif            catch(Exception ex)
44ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
45InBlock.gif                MessageBox.Show(ex.Message);
46ExpandedSubBlockEnd.gif            }

47ExpandedBlockEnd.gif        }

转载于:https://www.cnblogs.com/raymond19840709/archive/2007/01/12/618998.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值