[gdal-dev] Expanding a palette image to 3 bands

Frank Warmerdam warmerdam at pobox.com
Fri Aug 14 09:52:56 EDT 2009


On Fri, Aug 14, 2009 at 9:21 AM, Henneke, Amanda
M<amanda.m.henneke at boeing.com> wrote:
> Hello all-
>
> I have a need to expand a 1 band palette tif file into a 3 band (rgb) tif file.  I have found that gdal_translate -expand rgb will do this from the command line, but I was wondering if there was some way to do this within C# using the GDAL bindings?  I notice there is a ColorTable object and PaletteInterpretation object, but I haven't figured out yet (or seen anything online) about how to use these to expand the image.

Amanda,

You could skim the gdal_translate code to see how -expand rgb
works, but unfortunately it depends on access to VRT classes
that are not directly callable from C# or other swig bindings.  However,
you can compose the corresponding VRT XML directly in C# and
then "open" that VRT XML as a dataset that will have the expanded
bands.  This VRT dataset can then be passed to a CreateCopy() to
write out the expanded result.

I have attached the results of "gdal_translate -of VRT -expand rgb" on
a dataset as an example of the corresponding XML.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent
-------------- next part --------------
A non-text attachment was scrubbed...
Name: out.vrt
Type: application/octet-stream
Size: 1672 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20090814/a96e8a9a/out.obj


More information about the gdal-dev mailing list