[GRASS-dev] new r.out.gdal fails to preserve 8bit color

Roger Bivand Roger.Bivand at nhh.no
Wed Jan 17 04:12:37 EST 2007


On Wed, 17 Jan 2007, Moritz Lennert wrote:

> On 16/01/07 22:14, Markus Neteler wrote:
> > On Tue, Jan 16, 2007 at 09:53:41PM +0100, Markus Neteler wrote:
> >> On Tue, Jan 16, 2007 at 07:03:15PM +0100, Maciej Sieczka wrote:
> >>> Maciej Sieczka wrote:
> >>>> Vytautas,
> >>>>
> >>>> Exporting a CELL GRASS raster, value range 0-255, r.out.gdal issues an:
> >>>>
> >>>> ERROR 6: SetColorInterpretation() not supported for this dataset.
> >>>>
> >>>> and the output map is greyscale.
> >>> There is a discussion about this defect on the GDAL dev list:
> >>> http://www.nabble.com/r.out.gdal%3A-SetColorInterpretation%28%29-not-supported-tf3021127.html
> >>>
> >> Probably the mapgdal.c file of MapServer could be an inspiration?
> > 
> > I found some more:
> > 
> > http://www.nabble.com/Re:-How-to-set-a-ColorTable-from-scratch--p5000321.html
> > http://www.archivesat.com/FreeGIS_project/thread1933209.htm
> > 
> > and GDAL
> > apps/gdalwarpsimple.c
> > 
> > Still lost :-)
> 
> 
> In the very first thread, Frank says:
> 
> "Generally speaking to produce a GeoTIFF file with a color table after 
> using Create() to create it, you need to do the SetColorTable() *before* 
> writing any raster data."
> 
> I don't see any call to SetColorTable in main.c of r.out.gdal. Could 
> this be the problem ?

In the R rgdal package, we use R code to generate three byte RGB bands, 
then make a PCT from those. I'm not sure where on the GDAL site one can 
find a direct route to go from an external palette to filling the PCT, 
although it looks as though it is made up of nc colours each of four RGBA 
bytes (not tried). R function RGB2PCT and help pages show some ideas, C++ 
code in function RGDAL_GenCMap in src/gdal-bindings.cpp.

Roger


> 
> Moritz
> 
> _______________________________________________
> grass-dev mailing list
> grass-dev at grass.itc.it
> http://grass.itc.it/mailman/listinfo/grass-dev
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the grass-dev mailing list