Terragen --- Terragen™ Terrain File

Terragen terrain files store 16-bit elevation values with optional gridspacing (but not positioning). The file extension for Terragen heightfields is "TER" or "TERRAIN" (which in the former case is the same as Leveller, but the driver only recognizes Terragen files). The driver ID is "Terragen". The dataset is file-based and has only one elevation band. Void elevations are not supported.

Reading

dataset::GetProjectionRef() returns a local coordinate system using meters. The origin is offset back half a pixel to conform with pixels-as-areas (Terragen considers pixels as points). The coordinate (0, 0) will be at the center of the northwest pixel.

band::GetUnitType() returns meters.

Elevations are Int16. You must use the band::GetScale() and band::GetOffset() to convert them to meters.

 

Writing

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().

Call dataset::SetProjection() and dataset::SetGeoTransform() with your coordinate system details. Otherwise, the driver will not encode physical elevations properly. Geographic (degree-based) coordinate systems will be converted to a local meter-based system. No half-pixel origin shift is done since the Terragen format does not store a projection origin.

To maintain precision, a best-fit baseheight and scaling will be used to use as much of the 16-bit range as possible.

Elevations are Float32.

 

Roundtripping

Errors per trip tend to be a few centimeters for elevations and up to one or two meters for ground extents if degree-based coordinate systems are written. Large degree-based DEMs incur unavoidable distortions since the driver currently only uses meters.

 

History

v1.0 (Mar 26/06): Created.
v1.1 (Apr 20/06): Added Create() support and SIZE-only read fix.
v1.2 (Jun 6/07): Improved baseheight/scale determination when writing.
v1.3 (Jan 27/08): Pixels-as-areas correction when reading.

See Also: