码迷,mamicode.com
首页 > 其他好文 > 详细

ArcGis Engine 矢量图层和栅格图层的加载

时间:2016-08-05 00:35:51      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:


//此处为矢量图层的加载方法,由于图层本身是已经制作好了的MXD类工程文件,所以直接采用MXD的加载方式
       if
(axMapControl1.CheckMxFile(shpFile))//判断是否为MXD文件 { IArray pArry; pArry = axMapControl1.ReadMxMaps(shpFile, Type.Missing); IMap pMap; for (int i = 0; i < pArry.Count; i++) { pMap = pArry.get_Element(i) as IMap; if (pMap.Name == "Layers") { axMapControl1.MousePointer = esriControlsMousePointer.esriPointerHourglass; axMapControl1.LoadMxFile(shpFile, 0, Type.Missing); axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault; } }


 


    //此处为栅格图层的加载方式,需要打开IWorkSpace        
     string
filePath = "文件路径"; string pathName = System.IO.Path.GetDirectoryName(filePath); string fileName = System.IO.Path.GetFileName(filePath); IWorkspaceFactory pWSF; pWSF = new RasterWorkspaceFactoryClass(); IWorkspace pWS; pWS = pWSF.OpenFromFile(pathName, 0); IRasterWorkspace pRWS; pRWS = pWS as IRasterWorkspace; IRasterDataset pRasterDataset; pRasterDataset = pRWS.OpenRasterDataset(fileName); IRasterPyramid pRasPyrmid; pRasPyrmid = pRasterDataset as IRasterPyramid; if (pRasPyrmid != null) { if (!(pRasPyrmid.Present)) { pRasPyrmid.Create(); } } IRaster pRaster; pRaster = pRasterDataset.CreateDefaultRaster(); IRasterLayer pRasterLayer; pRasterLayer = new RasterLayerClass(); pRasterLayer.CreateFromRaster(pRaster); ILayer pLayer = pRasterLayer as ILayer; axMapControl1.AddLayer(pLayer, 2);//设置栅格图层的显示层次

 

ArcGis Engine 矢量图层和栅格图层的加载

标签:

原文地址:http://www.cnblogs.com/MansonsBlog/p/5738740.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!