Hello,
I am trying to bulk process a number of grids and export out geotiffs. I have been able to use IRasterLayerExport3 to create an RGB geotiff. However they all have black for a background as the tiff only saves with 3 bands, rather than having a four band RGBA. This is my first attempt at using the SDK
I am trying to emulate the ArcPro export raster functionality to save a raster with a color ramp.
The code I currently use looks like this:
IMapDocument pmapDocument = new MapDocument();
IMap pmap;
pmapDocument.Open(layerName);
pmap = pmapDocument.get_Map(0);
ILayer layer = pmap.Layer[0];
IRasterLayer rlayer = layer as IRasterLayer;
IRasterLayerExport3 r3 = (IRasterLayerExport3)r_export;
ISaveAs2 save_as = (ISaveAs2)rlayer;
r3.Force2RGB = true;
r3.NoData = 0;
r3.RasterLayer = rlayer;
IRasterWorkspace out_Workspace = OpenFileWorkspace(wsName);
IWorkspace ow = (IWorkspace)out_Workspace;
r3.Export(ow, outName, "TIFF");
Am I missing another process that I should be using instead of this?
Thanks
Hello @Richard_Nairn I like to trial this in interactive form first. I can get this to work with output to JP2's with the following
Output image is a 4 Band JP2 image with Alpha band
Hope this helps. some
Gordon
In ArcPro the manual export to geotiff with alpha works. In ArcMap 10.8.1 it only outputs a 3 band RGB with no alpha.
I need an automatic process as I have hundreds to do. It is going to another program so GeoTIFF is required. The issue is the automated way using ArcObjects does not seem to add the alpha channel. I have not tried the ArcPro SDK to see if I can do something similar.
Currently I post process using FME to change the 0,0,0 NoData to blank Alpha. It's just an extra processing step I am trying to see if I can do within one of my initial steps rather than.
@Richard_Nairn there is a really good dicusion here on the merits of the Export Raster tool v's the Copy Raster tool. They key is the Force RGB option
" Check the Force RGB check box to export the output raster as a three-band RGB raster dataset with the current renderer. Additionally, while exporting to formats such as TIFF, JP2, PNG, and MRF that support alpha bands, you can use this option to export the data as a four-band raster dataset with an alpha band to preserve the transparency settings of the original data"
It appears the copy raster tool does not have this capability but has the Ignore Background Value option which may be the same.
Hope this helps
Gordon