ArcEngine做栅格数据拉伸

时间:2022-08-19 20:54:10

//获得已打开的栅格数据

IRasterLayer rasterLayer = new RasterLayerClass();
rasterLayer = (IRasterLayer)axMapControl1.Map.Layer[0];
//实现渲染接口。单波段影像用IRasterRenderer接口足够,多波段影像用IRasterRGBRenderer接口。
IRasterRenderer rasterRender = new RasterRGBRendererClass();
rasterRender.Raster =rasterLayer.Raster;
IRasterRGBRenderer rasterRGBRender = rasterRender as IRasterRGBRenderer;
rasterRender.Update();
IRasterStretch2 rasterStretchType = rasterRGBRender as IRasterStretch2;
//esriRasterStretchTypesEnum是枚举类型,包含多个拉伸方式
rasterStretchType.StretchType = esriRasterStretchTypesEnum.esriRasterStretch_Custom;
rasterStretchType.StandardDeviationsParam = 2; //方差
rasterStretchType.StretchStatsType = esriRasterStretchStatsTypeEnum.esriRasterStretchStats_AreaOfView;
 
rasterLayer.Renderer = rasterRGBRender as IRasterRenderer;
axMapControl1.Refresh();