How to add a raster layer to a map

The code example in this article shows the basic steps to create a raster layer, set a raster renderer, and add it to a map to display.

Adding a raster layer to a map

Use the following code example in your application:
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();
    //Set the raster renderer. The default renderer will be used if passing a null value.
    if (rasterRenderer != null){
    //Add it to a map if the layer is valid.
    if (rasterLayer != null){
        IMap map = activeView.getFocusMap();

See Also:

How to create a raster classify renderer
How to create a raster stretch renderer
How to create a raster unique value renderer

Development licensingDeployment licensing
ArcGIS for Desktop AdvancedArcGIS for Desktop Advanced
ArcGIS for Desktop StandardArcGIS for Desktop Standard
ArcGIS for Desktop BasicArcGIS for Desktop Basic
Engine Developer KitEngine