[GRASS-dev] r.out.gdal vs gdal_translate vs gdalwarp

Hi

I have noticed that analogous options settings in r.out.gdal,
gdal_translate and gdalwarp result in GeoTIFF's of significantly
different sizes. Sorry for crossposting, but I have no idea if it is
and issue in GDAL or GRASS.

Take the following example, based on GRASS spearfish60 location, raster
elevation.dted:

$ r.out.gdal in=elevation.dted format=GTiff type=Byte out=grass_copy.tif

  grass_copy.tif = 36965 bytes

$ gdal_translate grass_copy.tif grass_trans_copy.tif

  grass_trans_copy.tif = 29153 bytes

$ gdalwarp grass_copy.tif grass_warp_copy.tif

  grass_warp_copy.tif = 36336 bytes

Each command does only a raw copy of input. Sizes of the r.out.gdal and
gdalwarp outputs are similar, but the gdal_translate output is 1/6
smaller. Is that normal?

Another example, with LZW compression:

$ r.out.gdal in=elevation.dted format=GTiff type=Byte out=grass_lzw.tif
createopt=COMPRESS=LZW

  grass_lzw.tif = 23497 bytes

$ gdal_translate -co "COMPRESS=LZW" grass_copy.tif grass_trans_lzw.tif

  grass_trans_lzw.tif = 21601 bytes

$ gdalwarp -co "COMPRESS=LZW" grass_copy.tif grass_warp_lzw.tif

  grass_warp_lzw.tif = 22868 bytes

Differences between the 3 tiffs here are not huge, yet still
significant. Is that OK? I thought each should be more less the same.

The only difference in the gdalinfo output of each of the 3 tiffs in
either the first or second example is 7 lines of metadata, which are
present in r.out.gdal and gdal_translate output while missing in
gdalwarp output. However, it is only 397 bytes, which is not enough to
explain kilobytes of differences.

Maciek

Maciej Sieczka wrote:

Hi

I have noticed that analogous options settings in r.out.gdal,
gdal_translate and gdalwarp result in GeoTIFF's of significantly
different sizes. Sorry for crossposting, but I have no idea if it is
and issue in GDAL or GRASS.

Take the following example, based on GRASS spearfish60 location, raster
elevation.dted:

$ r.out.gdal in=elevation.dted format=GTiff type=Byte out=grass_copy.tif

  grass_copy.tif = 36965 bytes

$ gdal_translate grass_copy.tif grass_trans_copy.tif

  grass_trans_copy.tif = 29153 bytes

$ gdalwarp grass_copy.tif grass_warp_copy.tif

  grass_warp_copy.tif = 36336 bytes

Each command does only a raw copy of input. Sizes of the r.out.gdal and
gdalwarp outputs are similar, but the gdal_translate output is 1/6
smaller. Is that normal?

Analysing the two files with tiffdump, I note:

grass_copy.tif:
StripByteCounts (279) LONG (4) 4<8170 8170 8170 8170>

grass_trans_copy.tif:
StripByteCounts (279) LONG (4) 4<8170 8170 8170 2090>

The difference is 6080 bytes, which is ~3/4 of the 7812 byte
difference between the files. Also:

grass_copy.tif:
34735 (0x87af) SHORT (3) 32<1 1 0 7 1024 0 1 1 1025 0 1 1 1026 34737 33 0 2049 34737 8 33 2054 0 1 9102 ...>
34737 (0x87b1) ASCII (2) 42<UTM Zone 13, Northern He ...>

grass_trans_copy.tif:
34735 (0x87af) SHORT (3) 32<1 1 0 7 1024 0 1 1 1025 0 1 1 1026 34737 21 0 2049 34737 6 21 2054 0 1 9102 ...>
34737 (0x87b1) ASCII (2) 28<NAD27 / UTM zone 13N|NAD ...>

[tag 34735 differs in the 15th field; 33 vs 21; I haven't looked up
the details on that tag, but it's likely to be GeoTIFF.]

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

I forgot to write that I'm using the current GRASS 6.3 CVS and GDAL
1.4.0 + CVS 2007-04-08. GDAL was built with internal TIFF and GEOTIFF libs.

Maciek