欢迎您来到GIS动力

加入收藏 免费注册 用户登陆 帮助中心
首页 新闻动态 技术专栏 银杏树下 学习考研 软件下载 求职招聘 许愿瓶 节日祝福 用户中心 精彩推荐 资源搜索 地图
专栏导航: AO开发 | SO开发 | ArcGIS桌面 | 超图桌面 | 开发语言 | 数据库 | WebGIS | 银杏文学 | 研究生考题 | FreeMap 谈天说地
   您现在位于: 首页技术专栏ArcGIS应用与开发AO开发 → 正文
矢量图层叠加求交分析
07-11-07 14:40:30 作者:3echo 出处:

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          {
 3              try
 4              {
 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
11                  // 叠加表
12                 pLayer = this .axMapControl1.get_Layer( 1 );
13                 ITable pOverlayTable = pLayer  as  ITable;
14
15                  // 叠加分析表
16                 IFeatureClassName pFeatClassName = new  FeatureClassNameClass();
17                 pFeatClassName.FeatureType = esriFeatureType.esriFTSimple;
18                 pFeatClassName.ShapeFieldName = " shape " ;
19                 pFeatClassName.ShapeType = pInputFeatClass.ShapeType;
20
21                  // 工作空间名称
22                 IWorkspaceName pNewWSName = new  WorkspaceNameClass();
23                 pNewWSName.WorkspaceFactoryProgID  =   " esriDataSourcesFile.ShapefileWorkspaceFactory " ;
24                 pNewWSName.PathName  =   @" C:\temp " ;
25
26                  // 数据集名称
27                 IDatasetName pDatasetName = pFeatClassName  as  IDatasetName;
28                 pDatasetName.Name = " ss " ;
29                 pDatasetName.WorkspaceName = pNewWSName; 
30
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
40                  this .axMapControl1.AddLayer((ILayer)pOutputFeatClass, 0 );
41                 axMapControl1.Update();
42             }

43              catch (Exception ex)
44              {
45                 MessageBox.Show(ex.Message);
46             }

47         }


(本文已被浏览 次)
发布人:admin
推荐给好友:发送给好友
上篇新闻:
下篇新闻:
相关评论
发表我的评论
  • 尊重网上道德,遵守《全国人大常委会关于维护互联网安全的决定》及中华人民共和国其他各项有关法律法;
  • 本站有权保留或删除您发表的任何评论内容;
  •   相关文章  
    叠加分析

    关于我们 友情链接 ┋ 与我在线 ┋ 管理 ┋ TOP
    网站当前版本:GisPower CMS V3.0
    『GIS 动力』- http://www.gispower.org/
    联系我们:webmaster#gispower.org
    Copyright (c) 2003-2007 GisPOwer.Org. All Rights Reserved.

                   滇ICP备05006901号