This is the manual for the command-line
scape_tool program that is
distributed with DIRSIG and can be used to generate polygon meshes for
terrains from a variety of input raster and point elevation datasets.
This tool is primarily derived from code developed at Carnegie Mellon
University (CMU) in the late 1990s. Mike Garland released the source
code for a program named
scape as a demonstration of the algorithms
(and the implementation of those algorithms) described in the paper
"Fast Polygonal Approximation of Terrains and Height Fields" written by
himself and Paul Heckbert. CMU maintains the original
website for all this
work, including softcopy versions of the paper and the original
The original tool focused on producing a triangular irregular network (TIN), which is a polygon mesh of triangles with irregularly spaced vertexes. This irregularity allows the mesh vertex density to be denser where there is more structure that needs to be represented by closer points to capture stronger vertical gradients. The general algorithm for producing a TIN involves evaluating the current mesh and choosing a location to insert a new vertex that cuts an existing triangle into two or more new triangles. There are multiple algorithms for choosing where to insert a new vertex. The original tool included a standard Delaunay triangulation algorithm, but it also introduced a set of "data dependant" algorithms. These alternate algorithms would insert a new vertex in an attempt to minimize mesh fit metrics such as height or slope errors.
scape_tool described here is simply an enhanced version of the original
code written by Garland. These enhancements include the following additions:
The program originally supported only input raster datasets using the STM format.
The program now supports ENVI image files as input using any datatype (although the core algorithm and data structures operate on 16-bit data, so 32-bit and floating point elevation data is scaled into 16-bits).
The program also supports irregularly spaced ASCII/Text point data. This allows point data from ladar systems to be used to create terrain meshes.
The program originally supported only output polygon meshes using a simple, non-standard format.
The code now writes to the commonly supported Alias/Wavefront OBJ file.
Useful Supporting Tools
The following additional tools are useful when working on converting from point or raster elevation data to facetized terrains:
The Geospatial Data Abstraction Library (GDAL) toolbox. GDAL is not only a library of useful functions for geospatial data manipulation, but also a toolbox of useful command-line tools for manipulating and converting georeferenced raster and vector data in commonly used formats.
The Meshlab tool is a graphical tool for processing and editing of facetized object data. It has decent support for importing common 3D mesh data formats, it has an expansive library of tools to process (filter, convert, etc.) loaded data, and it can save to the Alias/Wavefront OBJ file format, which is the most commonly used format for importing 3D geometry into a DIRSIG scene.
The DIRSIG Object Tool is a command-line tool that can be used to perform an number of common operations on facetized object data.
This section outlines workflows using a series of tools to convert common data formats into a terrain mesh.
Using a GeoTIFF or DTED input DEM
It is common for a DEM to stored in a GeoTIFF image container. The workflow for importing a GeoTIFF DEM is as follows:
Convert the GeoTIFF or DTED to Point Data
The first step is to convert the GeoTIFF or DTED raster data file to an
ASCII/Text XYZ file using the
gdal_translate tool from GDAL:
$ gdal_translate n40_w089_1arc_v2.tif -of XYZ n40_w089_1arc_v2.xyz
$ gdal_translate n40_w089_1arc_v2.dt2 -of XYZ n40_w089_1arc_v2.xyz
The output file consists of 3 columns: +W longitude (degrees), +N latitude (degrees) and altitude (meters).
Generate a TIN from the Point Data
The next step is to generate a TIN from the XYZ point data using the
scape_tool included with DIRSIG:
$ scape_tool --xyz_filename=n40_w089_1arc_v2.xyz --xyz_frame=geodetic \ --obj_filename=n40_w089_1arc_v2.obj --max_vertexes=100000
--xyz_frame option tells the tool that the input XYZ data is in geodetic
coodinates (latitude, longitude and altitude). The tool will then convert it
from this absolute coordinate system to a scene ENU coordinate system. In
addition to handling the horizontal conversion, it will correctly introduce the
curvature of the earth as geoid relative altitudes are converted to the Cartesian
altitudes of the Scene ENU coordinate system.
--max_vertexes option specifies the maximum number of vertexes to insert
into the mesh.
Post Process the TIN
The last step is some needed post-processing of the mesh in Meshlab.
Select File → Import Mesh to import the
n40_w089_1arc_v2.objfile produced in the last step.
Run the Filters → Cleaning and Repairing → Merge Close Vertices tool
This will loselessly compress the vertex data produced by the
scape_toolby finding duplicated vertexes (the same 3D point) in the vertex list.
Run the Filters → Normals, Curvature and Orientation → Compute Vertex * Normals tool
This will add vertex normals for a smoother appearing terrain.
Select File → Export Mesh to export the mesh back to the OBJ file.