public void Output(IRasterLayer rasterLayer) { //Create and fill the IRasterLayer object //IRasterLayer rasterLayer = new RasterLayerClass(); //rasterLayer.CreateFromDataset(productDataset); //rasterLayer.Renderer = StretchRenderer(rasterLayer.Raster); //Prepare the export var rle = new RasterLayerExport(); IRasterLayerExport rle2 = rle as IRasterLayerExport; rle2.RasterLayer = rasterLayer; rle2.Extent = rasterLayer.VisibleExtent; rle2.Force2RGB = false; //IRasterStorageDef rsd = new RasterStorageDef(); //rsd.CompressionType = esriRasterCompressionType.esriRasterCompressionUncompressed; //rle2.StorageDef = rsd; string ws = System.IO.Path.GetDirectoryName(ComboBoxInLayer.Text); string fbs = System.IO.Path.GetFileName(ComboBoxInLayer.Text); //IWorkspaceFactory pWork = new RasterWorkspaceFactory(); //IRasterWorkspace pRasterWs = pWork.OpenFromFile(ws, 0) as IRasterWorkspace; //Export file IWorkspaceFactory workspaceFactory = new RasterWorkspaceFactory(); IWorkspace workspace = workspaceFactory.OpenFromFile(ws, 0); var test = rle2.Export(workspace, "FILEX.TIF", "TIFF"); MessageBox.Show(""); }
public void Oput(IRasterLayer rasterLayer) { IRaster pRaster = rasterLayer.Raster; IRasterProps pRasterProps = (IRasterProps)pRaster; IRasterLayerExport rLayerExport = new RasterLayerExport(); rLayerExport.RasterLayer = rasterLayer; rLayerExport.Extent = pRasterProps.Extent; //设置提取栅格数据的范围即为Raster数据的范围 rLayerExport.SpatialReference = pRasterProps.SpatialReference; // 设置当前栅格数据的投影信息 IWorkspaceFactory pWF = new RasterWorkspaceFactory(); string filePath = System.IO.Path.GetDirectoryName(ComboBoxInLayer.Text); //string fbs = System.IO.Path.GetFileName(ComboBoxInLayer.Text); string fileName = ""; //Export file IWorkspaceFactory workspaceFactory = new RasterWorkspaceFactory(); //IWorkspace workspace = workspaceFactory.OpenFromFile(ws, 0); //string filePath = "", fileName = "", outputFormat = ""; // filePath = saveDG.FileName; fileName = "wew.tif"; //filePath = ""; // IWorkspace pRasterWorkspace = pWF.OpenFromFile("C:\\", 0); // IRasterDataset outGeoDataset = rLayerExport.Export(pRasterWorkspace, fileName, "TIFF"); }