[GRASS-dev] r.out.gdal: GeoTIFF colortable malformed?

Hi,

GeoTIFFs exported with r.out.gdal appear blank in QGIS 0.8 [1]. I have
reported that into QGIS bug tracker [1] supposing it was QGIS fault,
but I was told that:

"The tiff has a GRASS color table that is zero. See: $ gdalinfo
vegcover.tif | grep COLOR"

QGIS developers have hacked in a workaround for this issue. However, is
there anything which could be done in r.out.gdal to fix it at it's
roots? Or is a problem in GDAL maybe? Thanks for any hints.

Maciek

[1] https://svn.qgis.org/trac/ticket/643

Maciej Sieczka wrote:

Hi,

GeoTIFFs exported with r.out.gdal appear blank in QGIS 0.8 [1]. I have
reported that into QGIS bug tracker [1] supposing it was QGIS fault,
but I was told that:

"The tiff has a GRASS color table that is zero. See: $ gdalinfo
vegcover.tif | grep COLOR"

QGIS developers have hacked in a workaround for this issue. However, is
there anything which could be done in r.out.gdal to fix it at it's
roots? Or is a problem in GDAL maybe? Thanks for any hints.

Did you specify type=Byte or type=UInt16? The default for CELL maps is
Int32, and a 2^32 entry palette isn't feasible.

  $ r.out.gdal vegcover format=GTiff output=vegcover.tif
  ERROR 6: SetColorTable() only supported for Byte or UInt16 bands in TIFF format.
  Done!

[gdalinfo shows no colour table.]

  $ r.out.gdal vegcover format=GTiff output=vegcover.tif type=Byte
  Done!

[gdalinfo shows a colour table.]

Even with type=, the COLOR_TABLE_RULE* values are bogus; all entries
have zero for start, end and intensities:

  COLOR_TABLE_RULES_COUNT=6
  COLOR_TABLE_RULE_RGB_0=0.000000e+00 0.000000e+00 0 0 0 0 0 0
  COLOR_TABLE_RULE_RGB_1=0.000000e+00 0.000000e+00 0 0 0 0 0 0
  COLOR_TABLE_RULE_RGB_2=0.000000e+00 0.000000e+00 0 0 0 0 0 0
  COLOR_TABLE_RULE_RGB_3=0.000000e+00 0.000000e+00 0 0 0 0 0 0
  COLOR_TABLE_RULE_RGB_4=0.000000e+00 0.000000e+00 0 0 0 0 0 0
  COLOR_TABLE_RULE_RGB_5=0.000000e+00 0.000000e+00 0 0 0 0 0 0

This is because:

1. vegcover doesn't use colour rules but a fixed palette:

  #0 first color
  255 255 255
  0
  255 0 0
  255 255 0
  255 128 0
  0 0 255
  255 0 255
  0 255 0

[spearfish57/PERMANENT/colr/vegcover]

2. r.out.gdal is using the maximum value as the number of rules (hence
the COLOR_TABLE_RULES_COUNT=6) rather than the value returned by
G_colors_count().

I've committed a fix for point #2, so vegcover.tif won't have
COLOR_TABLE_RULES_COUNT or COLOR_TABLE_RULE_RGB_* tags.

--
Glynn Clements <glynn@gclements.plus.com>

Glynn Clements wrote:

Maciej Sieczka wrote:

GeoTIFFs exported with r.out.gdal appear blank in QGIS 0.8 [1].

Did you specify type=Byte or type=UInt16?

On https://svn.qgis.org/trac/ticket/643 you can read it was:

r.out.gdal input=vegcover format=GTiff type=Byte output=vegcover.tif

The default for CELL maps is
Int32, and a 2^32 entry palette isn't feasible.

  $ r.out.gdal vegcover format=GTiff output=vegcover.tif
  ERROR 6: SetColorTable() only supported for Byte or UInt16 bands in TIFF format.
  Done!

[gdalinfo shows no colour table.]

  $ r.out.gdal vegcover format=GTiff output=vegcover.tif type=Byte
  Done!

[gdalinfo shows a colour table.]

Even with type=, the COLOR_TABLE_RULE* values are bogus; all entries
have zero for start, end and intensities:

  COLOR_TABLE_RULES_COUNT=6
  COLOR_TABLE_RULE_RGB_0=0.000000e+00 0.000000e+00 0 0 0 0 0 0
  COLOR_TABLE_RULE_RGB_1=0.000000e+00 0.000000e+00 0 0 0 0 0 0
  COLOR_TABLE_RULE_RGB_2=0.000000e+00 0.000000e+00 0 0 0 0 0 0
  COLOR_TABLE_RULE_RGB_3=0.000000e+00 0.000000e+00 0 0 0 0 0 0
  COLOR_TABLE_RULE_RGB_4=0.000000e+00 0.000000e+00 0 0 0 0 0 0
  COLOR_TABLE_RULE_RGB_5=0.000000e+00 0.000000e+00 0 0 0 0 0 0

This is because:

1. vegcover doesn't use colour rules but a fixed palette:

  #0 first color
  255 255 255
  0
  255 0 0
  255 255 0
  255 128 0
  0 0 255
  255 0 255
  0 255 0

[spearfish57/PERMANENT/colr/vegcover]

2. r.out.gdal is using the maximum value as the number of rules (hence
the COLOR_TABLE_RULES_COUNT=6) rather than the value returned by
G_colors_count().

I've committed a fix for point #2, so vegcover.tif won't have
COLOR_TABLE_RULES_COUNT or COLOR_TABLE_RULE_RGB_* tags.

Thank you. I'll report back when I try the fixed version.

Regards,
Maciek