[GRASS-dev] Re: [GRASS GIS] #73: r.out.gdal tiff output does not work

GRASS GIS trac at osgeo.org
Thu Feb 28 21:24:22 EST 2008


#73: r.out.gdal tiff output does not work
----------------------+-----------------------------------------------------
  Reporter:  helena   |       Owner:  grass-dev at lists.osgeo.org
      Type:  defect   |      Status:  new                      
  Priority:  major    |   Milestone:  6.4.0                    
 Component:  default  |     Version:  svn-trunk                
Resolution:           |    Keywords:  r.out.gdal, tiff         
----------------------+-----------------------------------------------------
Comment (by hamish):

 (I see the same with 6.2.1's old script version of r.out.gdal)

 it works if the values are in the range of 0-255:
 {{{
   #spearfish
   r.out.gdal in=fields out=fields.tif type=Byte
   qiv fields.tif   # qiv is a quick image viewer
 }}}

 but not if all values are out of range:
 {{{
   r.info -r elevation.dem
     min=1066
     max=1840
   r.info -t elevation.dem
     datatype=CELL
   r.out.gdal in=elevation.dem out=elv.tif type=Byte

   gdalinfo -stats elv.tif | grep STATISTIC
     STATISTICS_MINIMUM=255
     STATISTICS_MAXIMUM=255
     STATISTICS_MEAN=255
     STATISTICS_STDDEV=0

   r.in.gdal in=elv.tif out=elv2
   r.info -r elv2
     min=255
     max=255
 }}}


 we can try with half the raster in range:
 {{{
   r.mapcalc "elev_0 = elevation.dem - 1066"
   r.info -r elev_0
     min=0
     max=774
   r.out.gdal in=elev_0 out=elv0.tif type=Byte
   gdalinfo -stats elv0.tif | grep STATISTIC
     STATISTICS_MINIMUM=0
     STATISTICS_MAXIMUM=254
     STATISTICS_MEAN=138.68943338231
     STATISTICS_STDDEV=56.526296226099
 }}}

 If I load elv0.tif into an image viewer it comes out as all black. But in
 Gimp if you use the eyedropper you can see the index number changes, but
 the palette is black for all 256 index entries.

 gdalinfo confirms palette info was not written to file:

 {{{
 Band 1 Block=1899x4 Type=Byte, ColorInterp=Palette
   NoData Value=255
   Metadata:
     COLOR_TABLE_RULES_COUNT=0
   Color Table (RGB with 256 entries)
     0: 0,0,0,255
     1: 0,0,0,255
     2: 0,0,0,255
     3: 0,0,0,255
     4: 0,0,0,255
 ...
   255: 0,0,0,255
 }}}


 I do not know how to apply the Gimp's Topographic.gpl color palette to the
 image's private "Colormap" index. It must be possible somehow, but I don't
 know Gimp well enough..

 If you want to store integer values >255 in the Tiff, you will have to use
 one of Int16,UInt16,UInt32,Int32[,CInt16,CInt32?].

 If you use type=Int32 etc you should preserve the CELL data for use in
 other GIS software, even if the saved palette is bogus.


 In the above elev_0 case you can see that the 0-774 raster exported as
 Byte (8bit) only preserves elevation values in the range of 0-254.

 Only Byte and UInt16 will attempt to write out a color palette to the
 GeoTIFF AFAIK.



 Hamish

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/73#comment:1>
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/


More information about the grass-dev mailing list