[Gdal-dev] r.out.gdal: SetColorInterpretation() not supported

Frank Warmerdam warmerdam at pobox.com
Tue Jan 16 11:42:47 EST 2007

Markus Neteler wrote:
> Hi,
> for some weeks we have a nice C implementation of r.out.gdal
> in GRASS, but a color table problem remains:
> GRASS 6.3.cvs (spearfish60): > r.out.gdal fields out=fields.tif
> ERROR 6: SetColorInterpretation() not supported for this dataset.
>  100%
> Done!
> GRASS 6.3.cvs (spearfish60): > r.info -t fields
> datatype=CELL
> GRASS 6.3.cvs (spearfish60): > r.info -r fields
> min=1
> max=63
> The (probably) relevant line in the main.c file is:
>     /* Set color interpretation. TODO: Implement this better ... */
>     GDALSetRasterColorInterpretation(hBand, ((band + 3) % 4 + GCI_RedBand));
> Maybe it fails on an 8 bit range?
> Suggestion are welcome as colorized export is an important thing,


The GeoTIFF driver provides very little post-creation control over band
color interpretations.  The actual implementation only supports marking
band 2 or 4 of a greyscale or rgb file as alpha.  All other efforts are
essentially passed on to the generic implementation which produces the
error you see.

That doesn't necessarily mean the color interpretation is set wrong, though
it could.

I would add that most other drivers also have no meaningful implementation
of this method.

My suggestion is to call:

   CPLPushErrorHandler( CPLQuietErrorHandler );

just before calling GDALSetRasterColorInterpretation() and then:


just afterwards.  This will at least supress the confusing message.

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    | President OSGeo, http://osgeo.org

More information about the Gdal-dev mailing list