I have a problem when trying to export a layer with renderer to a file. Basically, what I have at start is a correct IRasterDataset. Then I define a stretch renderer in form of IMultiPortColorRamp and apply it to IRasterLayer created from input IRasterDataset.

Please take a look at my code:

//Create and fill the IRasterLayer object
IRasterLayer rasterLayer = new RasterLayerClass();
rasterLayer.Renderer = StretchRenderer(rasterLayer.Raster);

//Prepare the export
var rle = new RasterLayerExport();
IRasterLayerExport2 rle2 = rle as IRasterLayerExport2;
rle2.RasterLayer = rasterLayer;
rle2.Extent = rasterLayer.VisibleExtent;
rle2.Force2RGB = false;
IRasterStorageDef rsd = new RasterStorageDef();
rsd.CompressionType = esriRasterCompressionType.esriRasterCompressionUncompressed;
rle2.StorageDef = rsd;

//Export file
IWorkspaceFactory workspaceFactory = new RasterWorkspaceFactory();
IWorkspace workspace = workspaceFactory.OpenFromFile(fileFolder, 0);
var test = rle2.Export(workspace, "FILEX.TIF", "TIFF");

The StretchRenderer function uses the same code as CreateMultiPartColorRamp here: http://www.onspatial.com/2011/02/arcobjects-create-multipart-color-ramp.html?m=2

This results in a proper export of GeoTIFF but without the renderer applied. The exported file is usable in ArcMap and it has the default stretched visualization available. What can I do to export this raster altogether with the renderer?

  • Did you try saving the layer as a layer file (.lyr) ? Commented Jan 20, 2016 at 16:07
  • Yes, I did. Layer file works very well, in ArcMap the renderer that was defined is applied by default.
    – Konrad
    Commented Jan 20, 2016 at 16:44

1 Answer 1


The solution to the problem is to use the RGB rendering by setting the property below.

rle2.Force2RGB = true;

For some reason the exported raster file has to be RGB. The second thing - once I imported the produced raster to ArcMap the colors where wrong. This is because ArcMap applies some default renderer properties to the raster. To overcome this problem, switch off Apply Gamma Stretch option in Symbology of Layer Properties window.

It was better to check first how raster export behaves in ArcMap and then to start developing a solution. All ArcObjects functions seem to be very closely related to appropriate functionalites in ArcMap.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.