C# GIS构建金字塔加载影像数据

 

 

        /// 
        /// 1、影像数据
        /// 
        /// 
        private void AddRasterData(FileInfo file)
        {
            try
            {
           
                    if (File.Exists(file.FullName))
                    {
                        string gdbpath = file.DirectoryName;
                        IWorkspaceFactory pWorkspaceFactory = new RasterWorkspaceFactory();
                        IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(gdbpath, 0);
                        IRasterWorkspace pRasterWorkspace = pWorkspace as IRasterWorkspace;
                        IRasterDataset pRasterDataset = pRasterWorkspace.OpenRasterDataset(file.Name);
                        //影像金字塔判断与创建
                        IRasterPyramid3 pRasPyrmid;
                        pRasPyrmid = pRasterDataset as IRasterPyramid3;
                        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;
                        _MapCtrl.AddLayer(pLayer);//0

                    }

                    //IRasterLayer rasterLayer = new RasterLayerClass();
                    //rasterLayer.CreateFromFilePath(imageFulePath);
                    //_MapCtrl.AddLayer(rasterLayer, 0);
                

            }
            catch (Exception lex)
            {
            }
          
        }
        

2、加载影像数据方法2


        /// 
        /// text
        /// 
        private void AAA()
        {
            string filePath = "E:\\数据\\123.tif";
            IRasterLayer rasterLayer = new RasterLayerClass();
            rasterLayer.CreateFromFilePath(filePath);
            IGeoDataset geoDataset = rasterLayer as IGeoDataset;
            mapControl.AddLayer((ILayer)geoDataset);
        }

 

你可能感兴趣的:(AE开发,C#)