原文 ArcEngine中打开各种数据源(WorkSpace)的连接(SDE、personal/File、ShapeFile、CAD数据、影像图、影像数据集)

ArcEngine 可以接受多种数据源。在开发过程中我们使用了如下几种数据源

1.企业数据库(SDE

企业数据库需要使用SDE来管理,所以需要使用SDE的Workspace来表示连接。在AE接口中,Workspace是由Factory打开的。代码如下: // //准备连接参数

ESRI.ArcGIS.esriSystem.IPropertySet pPropSet=new PropertySetClass();

pPropSet.SetProperty("server","服务器机器名" );

pPropSet.SetProperty("instance","SDE运行的端口号");

pPropSet.SetProperty("user","用户名");

pPropSet.SetProperty("password","口令" );

pPropSet.SetProperty("version","版本");

SdeWorkspaceFactory sdeWkspFact=new SdeWorkspaceFactoryClass();

IFeatureWorkspace pFeaWksp=(IFeatureWorkspace)sdeWkspFact.Open(pPropSet,0);

其中唯一需要解释的可能就是版本(version).对于没有使用版本或者第一次连接(没有建立空间数据库,当然没有版本了). 该处使用sde.DEFAULT这个版本。这是默认的版本。

iPropertySet:: setProperty

public void setProperty(string name,object value)

2.个人数据库(PersonalGeodatabaseFileGeodatabase)

ArcEngine中个人数据库为Access。

string filePath="E:\\tt.mdb";

AccessWorkspaceFactory fac=new AccessWorkspaceFactoryClass();

IFeatureWorkspace space=(IFeatureWorkspace)fac.OpenFromFile(filePath,0); 这是用的最多的一种方式.

如果是FileGeodatabasse,则将

FileGDBWorkspaceFactory pWSF = New FileGDBWorkspaceFactory;

IFeatureWorkspace pWS1= pWSF.OpenFromFile(sPath, 0);

如果用IPropertySet。如下:

//Personal Geodatabase e.g., database = "C:\\myData\\mypGDB.mdb"

public IWorkspace open_pGDB_Workspace(string database)

{

IPropertySet propertySet = new PropertySetClass();

propertySet.SetProperty("DATABASE", database);

IWorkspaceFactory workspaceFactory = new AccessWorkspaceFactoryClass();

return workspaceFactory.Open(propertySet, 0);

}

3.Shapefile文件

Shapefile和Access的打开方式有一点相同。也有差异。

//这是Shape所在的目录(注意:是目录)

string spacePath="E:\\shapefile";

IShapefileWorkspaceFactory fac=new ShapefileWorkspaceFactoryClass(); IFeatureWorkspace space=(IFeatureWorkspace)fac.OpenFromFile(spacePath,0);

IFeatureClass fc=space.openFeatureClass(“china”);

4.AutoCAD dwg文件

AutoCAD文件和一般的ESRI格式不同。所以代码会有一点点奇怪。假设有一个dwg文件为E:\\cad\\107.dwg 下面是打开的代码:

CadWorkspaceFactoryClass fac=new CadWorkspaceFactoryClass ();

String filePath="E:\\cad";

IFeatureWorkspace space=fac.OpenFromFile(filePath,0) as IFeatureWorkspace ;

下面是打开FeatureClass的代码:

//线

IFeatureClass polyline =space.OpenFeatureClass("107.dwg:Polyline");

IFeatureLayer layer=new CadFeatureLayerClass ();

layer.FeatureClass =polyline;

//点

IFeatureClass point=space.OpenFeatureClass ("107.dwg:Point");

layer=new CadFeatureLayerClass ();

layer.FeatureClass =point;

//面

IFeatureClass polygon=space.OpenFeatureClass ("107.dwg:Polygon");

layer=new CadFeatureLayerClass();

layer.FeatureClass =polygon;

//注记

IFeatureClass anno=space.OpenFeatureClass ("107.dwg:Annotation"); layer=new CadAnnotationLayerClass();

layer.FeatureClass =anno;

5.影像图文件

//文件路径

string filePath="E:\\image\\117.tif";

IRasterLayer rasterLayer=new RasterLayerClass();

rasterLayer.CreateFromFilePath(filePath );

6.数据库中的影像数据集。

//数据库连接

IWorkspace space=OpenSpace();

//打开数据库的方式

IRasterWorkspaceEx rasterSpace=(IRasterWorkspaceEx)space;

IRasterDataset rasterDataset=rasterSpace.OpenRasterDataset (setName.Name );

IRasterLayer rasLayer=new RasterLayerClass();

rasLayer.CreateFromDataset(rasterDataset);

IRasterWorkspaceEx:提供创建和打开栅格目录或栅格数据集的方法。

但是IRasterWorkspaceEx,IRasterWorkspace, IRasterWorkspace2都有OpenRasterDataset。IRasterWorkspace经常也可用于打开栅格数据,如:

pWorkspaceFactory = new RasterWorkspaceFactoryClass();

pRasterWorkspace = (IRasterWorkspace)pWorkspaceFactory.OpenFromFile(filePath, 0);

IRasterDataset pRasterDataset = (IRasterDataset)pRasterWorkspace.OpenRasterDataset(fileName);

IRasterLayer pRasterLayer = new RasterLayerClass();

pRasterLayer.CreateFromDataset(pRasterDataset);

[转] ArcEngine中打开各种数据源(WorkSpace)的连接的更多相关文章

  1. ArcEngine中打开各种数据源(WorkSpace)的连接(转)

    ArcEngine中打开各种数据源(WorkSpace)的连接 (SDE.personal/File.ShapeFile.CAD数据.影像图.影像数据集) ArcEngine 可以接受多种数据源.在开 ...

  2. ArcEngine中打开各种数据源(WorkSpace)的连接http://www.cnblogs.com/feilong3540717/archive/2011/08/07/2129906.html

    ArcEngine中打开各种数据源(WorkSpace)的连接 ArcEngine中打开各种数据源(WorkSpace)的连接 (SDE.personal/File.ShapeFile.CAD数据.影 ...

  3. ArcEngine中打开各种数据源(WorkSpace)的连接

    (SDE.personal/File.ShapeFile.CAD数据.影像图.影像数据集) ArcEngine 可以接受多种数据源.在开发过程中我们使用了如下几种数据源 1.企业数据库(SDE) 企业 ...

  4. ArcEngine中打开各种数据源(WorkSpace)的连接 (SDE、personal/File、ShapeFile、CAD数据、影像图、影像数据集)

    ArcEngine 可以接受多种数据源.在开发过程中我们使用了如下几种数据源 1.企业数据库(SDE) 企业数据库需要使用SDE来管理,所以需要使用SDE的Workspace来表示连接.在AE接口中, ...

  5. C#+ArcEngine中com对象的释放问题

    1.问题描述 最近在写C#下AE的开发,在循环获取数据并修改时碰到了两个问题"超出系统资源"和"超出打开游标最大数":在网上看了一些资料,发现都是说在循环中没有 ...

  6. Spring MVC 使用tomcat中配置的数据源

    Spring MVC 使用tomcat中配置的数据源 配置tomcat数据源 打开tomcat目录下的conf目录,编辑sever.xml目录.在<GlobalNamingResources&g ...

  7. 在ArcEngine中使用Geoprocessing工具-执行工具

    转自原文在ArcEngine中使用Geoprocessing工具-执行工具 来解析一下Geoprocessor类的Execute方法,他有两种重载,Execute(IGPProcess, ITrack ...

  8. ArcEngine中最短路径的实现

    原文 ArcEngine中最短路径的实现 最短路径分析属于ArcGIS的网络分析范畴.而ArcGIS的网络分析分为两类,分别是基于几何网络和网络数据集的网络分析.它们都可以实现最短路径功能.下面先介绍 ...

  9. SQL Server中配置ODBC数据源

    单击“开始→windows系统→控制面板”,打开控制面板 单击“管理工具→ODBC数据源(32位)”打开ODBC数据源配置对话框 在数据源配置对话框中单击“系统DSN”选项卡下的“添加”按钮,创建数据 ...

随机推荐

  1. 像Linq一样来使用Graphics

    Linq的链式编程用起来总是那样畅快淋漓,可惜在C#中并不是每时每刻都能有这么畅快的感觉,其中使用Graphics的时候就是,每次用Graphics绘制大量图形时尤其如此.GDI+的API功能很强大, ...

  2. 使用Yeoman搭建 AngularJS 应用 (12) —— 让我们搭建一个网页应用

    原文地址:http://yeoman.io/codelab/local-storage.html 安装Bower程序包 我们使用另一个Angular模块,"angular-local-sto ...

  3. NSFileHandle 和 NSFileManager的一些用法

    文件操作 NSFileManager 常见的NSFileManager文件的方法: -(BOOL)contentsAtPath:path 从文件中读取数据 -(BOOL)createFileAtPat ...

  4. [转载].Net中如何操作IIS(源代码)

    ///***********************************************************///************** IIS控制管理类 1.0 Beta ** ...

  5. [转载]HTML5 Audio/Video 标签,属性,方法,事件汇总

    <audio> 标签属性: src:音乐的URL preload:预加载 autoplay:自动播放 loop:循环播放 controls:浏览器自带的控制条 <audio id=& ...

  6. [转载]jQuery 1.9 移除了 $.browser 的替代方法获取浏览器类型

    jQuery 从 1.9 版开始,移除了 $.browser 和 $.browser.version , 取而代之的是 $.support . 在更新的 2.0 版本中,将不再支持 IE 6/7/8. ...

  7. HDU4611+数学

    /* 找规律 题意:abs(i%A - i%B) 对i从0~N-1求和 从0~N-1一个一个算必TLE,着A,B两者差相同的部分合并起来算 */ #include<stdio.h> #in ...

  8. UrlRewriteFilter 美化器的使用方法 伪静态化的解决方案(转)

    一,URL美化器简介 UrlRewriteFilter是一个用于改写URL的Web过滤器,类似于Apache的mod_rewrite.适用于任何Web应用服务器(如Resin,Orion,Tomcat ...

  9. 利用link标签rel="alternate stylesheet"属性实现界面动态换肤

    rel="stylesheet"属性指定将一个样式表立即应用到文档.rel="alternate stylesheet"属性将其作为备用样式表而在默认情况下禁用 ...

  10. nginx配置静态文件服务器

    搭建文件服务器 要点就是root目录,会自动指向索引文件 如: index, index.html等 server { client_max_body_size 4G; listen 80; ## l ...