I recently learned some gdal command line syntax in my attempt to convert some geotiff files to the Terragen format.
During my first attempt I noticed a message about nodata values:
gdalwarp -of TERRAGEN -co MINUSERPIXELVALUE=20 -co MAXUSERPIXELVALUE=1347 "src.tif" "dest.ter"
Creating output file that is 8743P x 6159L.
Processing input file src.tif
Using internal nodata values (eg. -3.40282e+038) for image src.tif
0...10...20...30...40...50...60...70...80...90...100 - done.
(GDAL 1.7.0b2, FWTools 2.4.7, released 2010/01/19)
However, after the conversion I opened up the file in Terragen and while no errors were presented, the file contained no terrain data. I proceeded to open the file in a hex editor and noticed that while a proper file header appears to be present, the majority of the data is a bunch of zeros. If I understand the Terragen format correctly, it appears either no "chunks" are present or they all contain values of zero.
This is in stark contrast to performing a conversion within Terragen itself - I can import the src.tif
file in Terragen and export a .ter
file. The terrain is present in all its glory within Terragen. Viewing this file in a hex editor I can see many "chunks" of non-zero data present throughout the file.
Strangely, the file generated by gdalwarp is roughly the same file size as the one generated by Terragen, again the difference being it is full of zeros.
I noticed that my version of gdalwarp was quite outdated, so I decided to jump on linux and use the gdal tool set there. I also decided to mix things up a bit and use gdal-translate instead:
$ gdal_translate -of TERRAGEN -co MINUSERPIXELVALUE=-4.452 -co MAXUSERPIXELVALUE=3052.968 src.tif dest.ter
Input file size is 8743, 6159
0...10...20...30...40...50...60...70...80...90...100 - done.
I even tried specifying "none" for the nodata value:
$ gdal_translate -of TERRAGEN -a_nodata none -co MINUSERPIXELVALUE=-4.452 -co MAXUSERPIXELVALUE=3052.968 src.tif dest.ter
Input file size is 8743, 6159
0...10...20...30...40...50...60...70...80...90...100 - done.
(GDAL 1.10.0, released 2013/04/24)
However, in each case the result was the same. The terragen output file was chock full of zeros. I suspect that I need to provide additional parameters to the gdal tools in order to properly convert the data to the terragen format. I'm just not sure where to start. Any ideas?
UPDATE 1
For reference, gdalinfo outputs:
I have both full output from gdalinfo -hist
and brief output from:
gdalinfo -nomd -norat -noct -nofl
I have also run the same query on the file that was converted by Terragen itself, the one that contains proper terrain data.
Brief outputs:
src.tif
dest.ter
proper-conversion.ter
Full outputs:
src.tif <---- ~5MB
dest.ter
proper-conversion.ter