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

Markus Neteler neteler at itc.it
Mon Jan 22 10:40:40 EST 2007


On Sun, Jan 21, 2007 at 12:08:26AM +0000, Glynn Clements wrote:
> Markus Neteler wrote:
> > On Fri, Jan 19, 2007 at 03:31:42PM +0000, Glynn Clements wrote:
> > > Markus Neteler wrote:
...
> > > > I tried on two machines. The exported file does not contains colors. I wonder
> > > > if you get a colored output file (did you try a Spearfish raster map?).
> > > 
> > > I haven't looked into the overall issue of colour tables in r.out.gdal
> > > (I'm entirely unfamiliar with the GDAL API), only the question of
> > > whether G_get_f_color_rule() works correctly (it appears to).
> > 
> > Right, it writes reasonable values (in my debug output).
> > So GDALSetMetadataItem() probably fails or something else is
> > missing.
> 
> Based upon ~5 minutes of looking at the GDAL code and gdal.h, I
> suspect that you need GDALSetRasterColorTable(hBand, hCT) in there
> somewhere. AFAICT, you're creating a colour table, and filling in the
> entries, but not actually using the completed colour table for
> anything.

Great, now it works. Fixed in CVS.

That's the difference: ~5 minutes of your time while I don't manage
it in an afternoon :-)

> BTW, hCT should be GDALColorTableH rather than GDALColorTableH*;
> GDALColorTableH is already a pointer.

Fixed, too.

Questions:
- do we need SetColorInterpretation? alias GDALSetRasterColorInterpretation()
- why does the second example below tell me
  ERROR 6: SetNoDataValue() not supported for this dataset.

But maybe that are questions for the GDAL list.

Examples, that now work with colors:

# categorial map export:
r.out.gdal roads out=roads.tif type=UInt16
qgis roads.tif

# numerical map export:
r.out.gdal elevation.dem out=elev.img format=HFA
qgis elev.img

Thanks again,
Markus




More information about the grass-dev mailing list