获取FeatureClass

1.从shape文件获取FeatureClass
复制代码
 1 /// <summary>
 2 /// 读取shape文件为FeatureClass
 3 /// </summary>
 4 ///Example: shape文件路径:C:\data\USA\States.shp                      
 5 /// <param name="string_ShapefileDirectory">shape文件的目录. 此处: "C:\data\USA"</param>
 6 /// <param name="string_ShapefileName">shape文件的名字,不包括后缀,后缀大家都知道是shp. 此处: "States"</param>
 7 /// <returns>返回FeatureClass接口</returns>
 8 /// <remarks></remarks>
 9 public ESRI.ArcGIS.Geodatabase.IFeatureClass GetFeatureClassFromShapefileOnDisk(System.String string_ShapefileDirectory, System.String string_ShapefileName)
10 {
11     System.IO.DirectoryInfo directoryInfo_check = new System.IO.DirectoryInfo(string_ShapefileDirectory);
12     if (directoryInfo_check.Exists)
13     {
14         //We have a valid directory, proceed
15         System.IO.FileInfo fileInfo_check = new System.IO.FileInfo(string_ShapefileDirectory + "\\" + string_ShapefileName + ".shp");
16         if (fileInfo_check.Exists)
17         {
18             //We have a valid shapefile, proceed
19 
20             ESRI.ArcGIS.Geodatabase.IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass();
21             ESRI.ArcGIS.Geodatabase.IWorkspace workspace = workspaceFactory.OpenFromFile(string_ShapefileDirectory, 0);
22             ESRI.ArcGIS.Geodatabase.IFeatureWorkspace featureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)workspace; // Explict Cast
23             ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = featureWorkspace.OpenFeatureClass(string_ShapefileName);
24 
25             return featureClass;
26         }
27         else
28         {
29             //Not valid shapefile
30             return null;
31         }
32     }
33     else
34     {
35         // Not valid directory
36         return null;
37     }    
38 }
复制代码

源:http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//00490000008m000000


2.从FeatureLayer选中要素获取FeatureClass
复制代码
 1 ///<summary>Returns a reference to the currently selected featureclass from the given contents view.从当前内容视图中选中的要素返回要素类的引用</summary>
 2 ///  
 3 ///<param name="currentContentsView">An IContentsView interface.内容视图接口</param>
 4 ///  
 5 ///<returns>An IFeatureClass interface or Nothing if not found.返回值</returns>
 6 ///   
 7 ///<remarks></remarks>
 8 public ESRI.ArcGIS.Geodatabase.IFeatureClass GetFeatureClassOfSelectedFeatureLayerInContentsView(ESRI.ArcGIS.ArcMapUI.IContentsView currentContentsView)
 9 {
10   if (currentContentsView == null)
11   {
12     return null;
13   }
14   if (currentContentsView.SelectedItem is ESRI.ArcGIS.Carto.IFeatureLayer)
15   {
16     ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)currentContentsView.SelectedItem; // Explicit Cast
17     ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = featureLayer.FeatureClass;
18 
19     return featureClass;
20   }
21   return null;
22 }
复制代码

 

源:http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/Get_FeatureClass_of_Selected_Feature_Layer_in_Contents_View_Snippet/00490000004r000000/



3.从Personal Geodatabase获取FeatureClass


4.从File Geodatabase获取FeatureClass

5.从SDE获取FeatureClass



posted @   道义相勖  Views(1886)  Comments(0Edit  收藏  举报
编辑推荐:
· .NET Core GC计划阶段(plan_phase)底层原理浅谈
· .NET开发智能桌面机器人:用.NET IoT库编写驱动控制两个屏幕
· 用纯.NET开发并制作一个智能桌面机器人:从.NET IoT入门开始
· 一个超经典 WinForm,WPF 卡死问题的终极反思
· ASP.NET Core - 日志记录系统(二)
阅读排行:
· 支付宝事故这事儿,凭什么又是程序员背锅?有没有可能是这样的...
· 在线客服系统 QPS 突破 240/秒,连接数突破 4000,日请求数接近1000万次,.NET 多
· C# 开发工具Visual Studio 介绍
· 在 Windows 10 上实现免密码 SSH 登录
· C#中如何使用异步编程
点击右上角即可分享
微信分享提示