Esempio n. 1
0
        //#######################以下函数可配合使用########################

        //**************************Load Raster Begin****************************

        //函数编号:RasterLoad-01
        //函数名:DirToMosaic
        //函数功能:把文件夹中的Raster文件合并到新的Raster文件中去
        //参数:sDir:栅格文件夹
        //      pDataset:最后合并的RasterDataset
        //备注:pDataset可以使Geodataset中的参数,如果不存在利用函数创建
        public void DirToMosaic(string sDir, IRasterDataset pDataset)
        {
            //load all raster datasets in the input directory to the raster dataset
            //the geodatabase raster dataset has to exist,
            //if not create it first with proper storage parameters.
            IWorkspaceFactory pWsFact = new RasterWorkspaceFactoryClass();;
            IWorkspace        pFileWs = pWsFact.OpenFromFile(sDir, 0);

            IRasterDatasetEdit pSDEDs = pDataset as IRasterDatasetEdit;

            IRasterDataset2 pRasterDs;

            // load raster datasets from the dir
            IEnumDataset pEunmDatasets = pFileWs.get_Datasets(esriDatasetType.esriDTRasterDataset);

            pEunmDatasets.Reset();

            pRasterDs = pEunmDatasets.Next() as IRasterDataset2;
            while (!(pRasterDs == null))
            {
                //!!!pRasterDs.CompleteName;
                pSDEDs.Mosaic(pRasterDs.CreateFullRaster(), 0.5);
                //!!!注意IRasterDataset2::CreateFullRaster()方法可以简单实现从RasterDataset到Raster的转换
                pRasterDs = pEunmDatasets.Next() as IRasterDataset2;
            }

            //cleanup

            pEunmDatasets = null;
            pRasterDs     = null;
            pWsFact       = null;
            pSDEDs        = null;
            pFileWs       = null;
        }
Esempio n. 2
0
        //函数编号:Raster-07
        //函数名:MosaicRasterToGDBRaster
        //函数功能:Raster文件Mosaic到SDE Raster文件中
        //参数:
        public void MosaicRasterToGDBRaster(IRasterDataset pRasterFile, IRasterDatasetEdit pGDBRasterDs)
        {
            try
            {
                IRaster         pRaster;
                IRasterDataset2 pRasterDs = pRasterFile as IRasterDataset2;
                //IDataset pDs;

                pRaster = pRasterDs.CreateFullRaster(); //CreateFullRaster()方法只有IRasterDataset2有
                pGDBRasterDs.Mosaic(pRaster, 0.5);      //no resample

                pRasterDs = null;
                pRaster   = null;
                //pDs = null;
            }
            catch (Exception e)
            {
                if (e is StackOverflowException ||
                    e is OutOfMemoryException)
                {
                    throw;
                }
            }
        }
Esempio n. 3
0
        private void MosaicRasterToGDBRaster(IRasterDataset pRasterFile, IRasterDatasetEdit pGDBRasterDs)
        {
            try
            {
                IRaster pRaster;
                IRasterDataset2 pRasterDs = pRasterFile as IRasterDataset2;
                //IDataset pDs;

                pRaster = pRasterDs.CreateFullRaster();//CreateFullRaster()方法只有IRasterDataset2有
                pGDBRasterDs.Mosaic(pRaster, 0.5); //no resample

                pRasterDs = null;
                pRaster = null;
                //pDs = null;
            }
            catch (Exception e)
            {
                if (e is StackOverflowException ||
                    e is OutOfMemoryException)
                    throw;
            }
        }