Adding a raster layer to a map
Use the following code example in your application:
[Java]
static void addRasterLayer(IActiveView activeView, IRasterDataset rasterDataset,
IRasterRenderer rasterRenderer)throws Exception{
//Create a raster layer from a raster dataset. You can also create a RasterLayer from a raster.
IRasterLayer rasterLayer = new RasterLayer();
rasterLayer.createFromDataset(rasterDataset);
//Set the raster renderer. The default renderer will be used if passing a null value.
if (rasterRenderer != null){
rasterLayer.setRendererByRef(rasterRenderer);
}
//Add it to a map if the layer is valid.
if (rasterLayer != null){
IMap map = activeView.getFocusMap();
map.addLayer((ILayer)rasterLayer);
}
}
See Also:
How to create a raster classify rendererHow to create a raster stretch renderer
How to create a raster unique value renderer
Development licensing | Deployment licensing |
---|---|
ArcInfo | ArcInfo |
ArcEditor | ArcEditor |
ArcView | ArcView |
Engine Developer Kit | Engine Runtime |