AE开发技术文档--8种数据访问方法-阿里云开发者社区

开发者社区> 云计算> 正文

AE开发技术文档--8种数据访问方法

简介:

转自原文 AE开发技术文档--8种数据访问方法

1、shapefile

IWorkspaceFactory pWorkspaceFactory;
pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
IFeatureWorkspace pFeatWS;
pFeatWS = pWorkspaceFactory.OpenFromFile(@"D:\Data", 0) as IFeatureWorkspace;

//打开一个要素类
IFeatureClass pFeatureClass = pFeatWS.OpenFeatureClass("Cities");

2、coverage

Coverage 是一个集合,它可以包含一个或多个要素类。Coverage 数据的工作空间也是它所在的文件夹;由于Coverage 可以包含多个要素类,得到工作空间后在打开具体的要素类时可以用“Coverage 名称:要素类名称”,例如下面代码中的“basin:polygon”。

IWorkspaceFactory pFactory = new ArcInfoWorkspaceFactoryClass();
IWorkspace pWorkspace = pFactory.OpenFromFile(@"D:\ArcTutor\TopologyData", 0);
IFeatureWorkspace pFeatWorkspace = pWorkspace as IFeatureWorkspace;
IFeatureClass pFeatureClass = pFeatWorkspace.OpenFeatureClass("basin:polygon");

3、Geodatabase

   Personal Geodatabase 数据的工作空间指的是扩展名为mdb 的文件。以下是打开位于Monto.mdb 中的Water 要素类的代码。

IWorkspaceFactory pFactory = new AccessWorkspaceFactoryClass();
IWorkspace pWorkspace = pFactory.OpenFromFile(@"D:\ArcTutor\Monto.mdb", 0);
IFeatureWorkspace pFeatWorkspace = pWorkspace as IFeatureWorkspace;
IFeatureClass pFeatureClass = pFeatWorkspace.OpenFeatureClass("Water")

4、ArcSDE(Enterprise Geodatabase)

IWorkspaceFactory pWorkspaceFactory = new SdeWorkspaceFactoryClass();
IPropertySet propSet = new PropertySetClass();
propSet.SetProperty("SERVER", "actc");
propSet.SetProperty("INSTANCE", "5151");
propSet.SetProperty("USER", "apdm");
propSet.SetProperty("ASSWORD", "apdm");
propSet.SetProperty("VERSION", "SDE.DEFAULT");
IWorkspace pWorkspace = pWorkspaceFactory.Open(propSet, 0);
IFeatureWorkspace pFeatWS = pWorkspace as IFeatureWorkspace;
IFeatureClass pFeatureClass= pFeatWS.OpenFeatureClass("ControlPoint");

5、Tin

IWorkspaceFactory pWSFact = new TinWorkspaceFactoryClass();
IWorkspace pWS = pWSFact.OpenFromFile(@"D:\ArcTutor\3DAnalyst", 0);
ITinWorkspace pTinWS = pWS as ITinWorkspace;
ITin pTin = pTinWS.OpenTin("mal");

6、栅格数据

IWorkspaceFactory rasterWorkspaceFactory = new RasterWorkspaceFactoryClass();
IRasterWorkspace rasterWorkspace =rasterWorkspaceFactory.OpenFromFile(@"D:\data\grid", 0) as IRasterWorkspace;
IRasterDataset rasterDataset= rasterWorkspace.OpenRasterDataset("ca_hillshade");

7、CAD

以下代码是打开位于D:\ArcTutor\Editor\ExerciseData\EditingFeatures 文件夹下的buildings.dxf 中的
多边形要素类。

IWorkspaceFactory pCadwf = new CadWorkspaceFactoryClass();
IWorkspace pWS =
pCadwf.OpenFromFile(@"D:\ArcTutor\Editor\ExerciseData\EditingFeatures", 0);
IFeatureWorkspace pCadFWS = pWS as IFeatureWorkspace;
IFeatureClass pFeatClass = pCadFWS.OpenFeatureClass("buildings.dxf:polygon");

8、一般关系表

//创建一个连接
IPropertySet pPropset;
pPropset = new PropertySetClass();
pPropset.SetProperty("CONNECTSTRING",
@"rovider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Company.mdbersist Security
Info=False");
//创建一个新的OleDB工作空间并打开
IWorkspaceFactory pWorkspaceFact;
IFeatureWorkspace pFeatWorkspace;
pWorkspaceFact = new OLEDBWorkspaceFactoryClass();
pFeatWorkspace = pWorkspaceFact.Open(pPropset, 0) as IFeatureWorkspace;
ITable pTTable = pFeatWorkspace.OpenTable("Custom");

 

没有整理与归纳的知识,一文不值!高度概括与梳理的知识,才是自己真正的知识与技能。 永远不要让自己的自由、好奇、充满创造力的想法被现实的框架所束缚,让创造力自由成长吧! 多花时间,关心他(她)人,正如别人所关心你的。理想的腾飞与实现,没有别人的支持与帮助,是万万不能的。





    本文转自wenglabs博客园博客,原文链接:http://www.cnblogs.com/arxive/p/6110106.html,如需转载请自行联系原作者


版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
云计算
使用钉钉扫一扫加入圈子
+ 订阅

时时分享云计算技术内容,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。

其他文章