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)的连接 (SDE、personal/File、ShapeFile、CAD数据、影像图、影像数据集)的更多相关文章

  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)的连接

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

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

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

  5. 数据库、ArcCatalog空间数据源正常访问,数据库设置没问题时,ArcEngine连接SDE时报"ORA-12560: TNS: 协议适配器错误"的解决办法;ArcEngine连接SDE总结

    碰到的问题描述: 通过C# 基于ArcEngine写SDE直连的时候测试项目连接属性设置为如下: tPropSet.SetProperty("User", "GISDAT ...

  6. 自编的CHtmlView浏览器,怎么截获超连接,不让新窗口在IE中打开

    blog <自编的CHtmlView浏览器,怎么截获超连接,不让新窗口在IE中打开>    http://bbs.csdn.net/topics/10299197    http://so ...

  7. 如何修复在Microsoft Azure中“虚拟机防火墙打开,关闭RDP的连接端口”问题

     注:下列步骤并不一定适用所有场景,提供思路,请灵活应用 我们在使用Microsoft Azure 中Windows 虚拟机,有时会发生错误打开防火墙或一些管家软件错误的关闭了"远程桌面 ...

  8. 在Chrome中打开网页时出现以下问题 您的连接不是私密连接 攻击者可能会试图从 x.x.x.x 窃取您的信息(例如:密码、通讯内容或信用卡信息)

    现象:在Chrome中打开网页时出现以下问题 您的连接不是私密连接 攻击者可能会试图从 x.x.x.x 窃取您的信息(例如:密码.通讯内容或信用卡信息). 当点开"了解详情"后显示 ...

  9. JDBC数据源 使用JNDI连接池实现数据库的连接

    0.引言 许多Web应用程序需要通过JDBC驱动程序访问数据库,以支持该应用程序所需的功能.Java EE平台规范要求Java EE应用程序服务器为此目的提供一个DataSource实现(即,用于JD ...

随机推荐

  1. python 文件操作的相对路径和绝对路径(windows)

    1.相对路径 windows  '.\'表示当前路径 with open(r'.\db\123.txt','w',encoding='utf-8') as f: f.write('abc') 2.绝对 ...

  2. linux编译esp8266

    编译工具是xtensa-lx106-elf-gcc,一般会在~/.bashrc文件下添加 export PATH="$HOME/esp-open-sdk/xtensa-lx106-elf/b ...

  3. Python3之threading模块

    import threading # Tips:一个ThreadLocal变量虽然是全局变量, # 但每个线程都只能读写自己线程的独立副本,互不干扰. # ThreadLocal解决了参数在一个线程中 ...

  4. vue项目中,点击按钮复制其内容

    <el-table-column label="推广链接" align="center"> <template slot-scope=&quo ...

  5. js设置日期格式

    取数据时后台返回的日期数据是一串数字,前台显示时需要将时间格式化,通过以下代码转换. var format = function(time, format){    var t = new Date( ...

  6. 课时5:POW,POS,DPOS(矿工/矿机,工作证明)

    比特币钱包

  7. LibreOffice/Calc:带条件判断的求和

    本文适用于LibreOffice Calc 5.1.6.2 + Ubuntu 16.04,熊猫帮帮主@cnblogs 2018/3/7 以下图为例,假设要根据C列对D列中被选中单元进行求和,即对D列中 ...

  8. CSS3选择器:nth-child和:nth-of-type的差异

    p:nth-child(2)表示这个元素要是p标签,且是第二个子元素,是两个必须满足的条件. <section> <div>我是一个普通的div标签</div> & ...

  9. hdu 5791 Two 二维dp

    Two Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submiss ...

  10. matplotlib中 plt.plot() 函数中**kwargs的参数形式

    plt.plot(x, y, **kwargs) **kwargs的参数大致有如下几种: color: 颜色 linestyle: 线条样式 marker: 标记风格 markerfacecolor: ...