首页 > 其他 > 详细

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

时间:2016-08-05 00:34:25      阅读:180      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!