ArcEngine 加载栅格影像图并建立金字塔

一般情况加载栅格影像图,但没建立金字塔,导致软件卡死~
其实方法很简单,只需添加pRasterPyramid.BuildPyramid(-1, rstResamplingTypes.RSP_NearestNeighbor)即可。
一、方法代码如下:
///
/// 从文件夹中加载栅格数据的静态方法
///
/// 栅格文件的路径
/// 返回加载的栅格IRaster
public static void LoadRasterFromFile(string fullpath, ref IRaster raster)
{
int index = fullpath.LastIndexOf("\");
string path = fullpath.Substring(0, index);
string name = fullpath.Substring(index + 1);
IWorkspaceFactory WorkspaceFactory = new RasterWorkspaceFactoryClass();
IWorkspace Workspace = WorkspaceFactory.OpenFromFile(path, 0);
IRasterWorkspace RasterWorkspace = Workspace as IRasterWorkspace;
IRasterDataset RasterDataset = RasterWorkspace.OpenRasterDataset(name);
IRasterPyramid3 pRasterPyramid = RasterDataset as IRasterPyramid3;
if (pRasterPyramid != null && !pRasterPyramid.Present)
{
FrmWaitProgress frm = new FrmWaitProgress(name+":构建金字塔中…");
frm.Show();
frm.SetText(“构建金字塔,请稍等…”);
Application.DoEvents();
//-1代表创建全部级别的金字塔,0代表删除金字塔,其它代表创建对应级别的金字塔
pRasterPyramid.BuildPyramid(-1, rstResamplingTypes.RSP_NearestNeighbor);
Application.DoEvents();
frm.SetText(name+":金字塔创建成功!");
Application.DoEvents();
frm.Close();
}
raster = RasterDataset.CreateDefaultRaster();
System.Runtime.InteropServices.Marshal.ReleaseComObject(RasterDataset);
System.Runtime.InteropServices.Marshal.ReleaseComObject(RasterWorkspace);
System.Runtime.InteropServices.Marshal.ReleaseComObject(Workspace);
System.Runtime.InteropServices.Marshal.ReleaseComObject(WorkspaceFactory);
}

你可能感兴趣的:(C#,gis)