1

I'm attempting to use the tools to convert some files I have to the Terragen format. I was hoping to use either gdal_translate or gdalwarp in a similar fashion to this post. (though I should admit I am not sure which tool may be more appropriate for my task)

However, when I issue either command it exits with an error, in fact, the same error:

$ gdal_translate -of Terragen src.tif dest.ter
Input file size is 8743, 6159
0ERROR 1: Inverted, flat, or unspecified span for Terragen file.

$ gdalwarp -of Terragen src.tif dest.ter
Creating output file that is 8743P x 6159L.
ERROR 1: Inverted, flat, or unspecified span for Terragen file.

I quickly stumbled upon a post (which also points to gdal documentation) stating that I need to specify the span of elevation values:

Use the Create call. Set the MINUSERPIXELVALUE option (a float) to the lowest elevation of your elevation data, and MAXUSERPIXELVALUE to the highest. The units must match the elevation units you will give to band::SetUnitType().

Were I developing my own utility that used libgdal, this information would be applicable. However, instead of developing a new utility to achieve the conversion - I'd rather use the existing gdal tools if possible ( , ).

Is it possible to specify the min/max elevation values using any existing tools?

  • FYI, as mentioned by user30184 in this comment, it appears the Terragen driver in GDAL is quite outdated and may result in unwanted outputs. So if you plan to use it, tread lightly. – dtmland Apr 3 '15 at 22:44
3

For merely converting a raster from one format to another, many of the GDAL tools will do that along with their specialized functions so either GDALWARP or GDAL_TRANSALTE will do fine for your purposes (which also explains why they give you the same error).

The information you mention in the documentation in your links is applicable to using GDAL. Most of the GDAL tools have a "-co" switch (Creation Options). Scroll down in the tool's documentation and you'll see the explanation of each switch listed in the synopsis at the top of the page. The Creation Options are towards the bottom in this case. This is where you set the MINUSERPIXELVALUE and MAXUSERPIXELVALUE.

So, for instance I have a DTM file called 'HP.asc'. gdalinfo tells me it has a min of 20m and a max of 1347m. So I would issue the following command:

C:\OSGeo4W64\bin>gdalwarp -of TERRAGEN -co MINUSERPIXELVALUE=20 -co MAXUSERPIXELVALUE=1347 "c:\someSrcPath\HP40.asc" "c:\someDestination\HP40.ter"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.