Creating a raster stretch renderer
See the following code example:
[Java]
static IRasterRenderer stretchRenderer(IRasterDataset rasterDataset)throws Exception{
//define the from and to colors for the color ramp
IRgbColor fromColor = new RgbColor();
fromColor.setRed(255);
fromColor.setGreen(0);
fromColor.setBlue(0);
IColor toColor = new RgbColor();
fromColor.setRed(0);
fromColor.setGreen(255);
fromColor.setBlue(0);
//create the color ramp
IAlgorithmicColorRamp colorRamp = new AlgorithmicColorRamp();
colorRamp.setSize(255);
colorRamp.setFromColor(fromColor);
colorRamp.setToColor(toColor);
boolean[] createColorRamp = {
false
};
colorRamp.createRamp(createColorRamp);
//create a stretch renderer
IRasterStretchColorRampRenderer stretchRenderer = new
RasterStretchColorRampRenderer();
IRasterRenderer rasterRenderer = (IRasterRenderer)stretchRenderer;
//set renderer properties
IRaster raster = rasterDataset.createDefaultRaster();
rasterRenderer.setRasterByRef(raster);
rasterRenderer.update();
stretchRenderer.setBandIndex(0);
stretchRenderer.setColorRamp(colorRamp);
//set the stretch type
IRasterStretch stretchType = (IRasterStretch)rasterRenderer;
stretchType.setStretchType
(esriRasterStretchTypesEnum.esriRasterStretch_StandardDeviations);
stretchType.setStandardDeviationsParam(2);
return rasterRenderer;
}
See Also:
How to add a raster layer to a mapDevelopment licensing | Deployment licensing |
---|---|
ArcInfo | ArcInfo |
ArcEditor | ArcEditor |
ArcView | ArcView |
Engine Developer Kit | Engine Runtime |