0

I recently learned some gdal command line syntax in my attempt to convert some files to the Terragen format.

During my first attempt I noticed a message about 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 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 was quite outdated, so I decided to jump on and use the gdal tool set there. I also decided to mix things up a bit and use 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 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 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

3
  • 1
    Show us the report from gdalinfo -hist from src.tif and dest.ter
    – user30184
    Apr 3, 2015 at 18:08
  • @user30184 The info is now posted.
    – dtmland
    Apr 3, 2015 at 18:53
  • 1
    The Terragen driver seems to be unmaintained trac.osgeo.org/gdal/log/trunk/gdal/frmts/terragen. Created 8 years ago and last real edit 5 years ago. But you are using an ancient GDAL version from FWTools (GDAL is at v. 1.11.2 now) so it should work as it used to. Sorry, this was first time I heard about such format and I fear I can't help. I suspect that something goes wrong with float32 - int16 conversion.
    – user30184
    Apr 3, 2015 at 22:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.