Converting Elevation DEMs to 3D Tiles

3D Tiles is an open standard for organizing massive geometry datasets into a spatial data structure for efficient access and rendering of geospatial data. Terrain data is well suited for this format, and the Ansys Systems Tool Kit® (STK®) application offers a tool (AgTerrain2Tiles) to convert elevation and imagery data into a 3D Tileset.

AgTerrain2Tiles is a utility designed to take a collection of files that define a single resolution data source and build a 3D tileset representing the data source. If you provide an optional collection of imagery files, the STK software will build the imagery into the resulting collection of glTF content files.

Data source inputs

A data source is defined as a collection of source elevation files, such as TIFs and DEMs, that originates from a sole data provider. Examples of this include the USGS 3DEP 1/3 arc second elevation data, where you can select one or more elevation rasters as inputs for this conversion process.

It’s important that data is at a consistent resolution, such as 1/3 arc seconds (about 10 ms), for all input files. The processing tool uses the maximum resolution of the input data to determine the depth of the resulting 3D tileset tree.

Command line options

From a command prompt, go to the STK Install location’s bin directory. Show the help by running the conversion tool and passing in the --help flag:

.\AgTerrain2Tiles.exe --help

The available command line options are summarized in the table below:

Option Description Default Value
--terrain [Required] Identifies the file or directory that contains the input terrain elevation data. n/a
--imagery Identifies the file or directory specifying the input imagery data. n/a
--outputDir Defines the output directory where the resulting tileset will be placed. Current directory
--help Shows the STK Help. n/a
--toMetersFactor Scales input height values to meters. 1.0
--name Defines the output root directory where the resulting tileset will be placed. n/a
--imageryFilter Specifies the filtering algorithm (nearest or bilinear) to use when imagery is sampled. Nearest processes faster, and Bilinear is higher quality. bilinear
--heightReference Specifies the height reference (vertical datum) for all elevations in the terrain source. You must specify one of the following: ellipsoid, egm96, egm2008, navd88, or marsgmm3. ellipsoid
--combine Builds a (non-overlapping) tileset in the target tileset's location. Both the root node of this tileset and the target tileset root(s) are combined under a single parent root node. This is the recommended way to merge two disjoint tilesets, such as a polar projection-based tileset with an equirectangular-based tileset. n/a
--compression Directs the utility to compress tile geometry. Only geometry compression through the glTF "meshopt_compression" extension is supported by specifying "--compression=meshopt". Tilesets generated with compression=meshopt are only supported by STK version 13.1.0 (2026r1) and greater. n/a
--extensions Defines file extensions that are used to filter input files specified in -- terrain and --imagery options. You can specify two or more extensions by using a comma-separated list (*.csv). .tif, .lbl. tiff, .flt
--saveConfig Saves the current command line options to a JSON file. n/a
--config.json Loads command line options from a JSON configuration file. n/a
--resume Resumes processing, skipping over tiles that have already been written. n/a
--ellipsoid

Tells the processor to use an ellipsoid as the reference shape when constructing the terrain geometry. If you prefer not to use the default value, you can specify one of the following values:

  • earth
  • moon
  • mars
  • a comma-separated pair of numbers specifying semimajor axis and semiminor axis

You must apply this option when working with polar data.

The utility will define the ellipsoid from the semimajor and semiminor axes on the raster.

When defining a terrain or imagery data source, the value can refer to either a single raster file or a directory containing many files that describe a data source. When you specify a directory, the utility recurses through the directory tree and gathers all files that match the extensions listed by the "--extension" option, always including the default extensions listed in the table above.

All files in a data source should be of the same grid space resolution; you cannot us two or more terrain resolutions.

Saving and reloading a set of command line options

Specifying all options via command line can be error prone and tedious. Consider saving sets of command line options for future use using the --saveConfig=[filename] command option. You can then use the --config.json=[filename] command option to load a set.

The config.json file is the only mechanism available that enables you to define data source attribution as well as an attribution string for the tileset author to be embedded in the tileset. An example configuration file is provided below, describing the configuration used to build a small tileset containing Shackleton’s peak on the Lunar surface:

Copy

Json code example

{
    "configVersion" : 1,
    "attribution" : "Copyright ANSYS, Inc",
    "outputDir" : "C:/Terrain/out",
    "name" : "shackleton",
    "terrain" : [
        {
            "input" : "C:/Terrain/Lunar/LDEM_shackleton_20m.tif",
            "attribution" : "Terrain derived from LOLA LDEM, Improved LOLA Elevation Maps for South Pole Landing Sites, Sept 2021.",
            "toMeters" : 1000.0
        }
    ],
    "imagery" : [
        {
            "input" : "C:/Imagery/Lunar/NAC_ROI_SHKLTNPKLO1_P888S1247.tif",
            "attribution" : "NAC_ROI_SHKLTNPKLO1, Optimized Illuminated Terrain Coverage of the Candidate Artemis III Landing Sites with LROC nac controlled Mosaics, 2023."
        }
    ]
}

Examples

Process a TIF file that includes the half-dome feature from Yosemite National Park. This dataset was retrieved from the USGS National Viewer, which defines elevation data in the North American Vertical Datum, 1988 (NAVD88). Therefore, you must set the heightReference to navd88 to ensure that AgTerrain2Tiles interprets height values accurately. In this example, this configuration is saved to the halfdome.json file.

.\AgTerrain2Tiles.exe --terrain=C:\Terrain\halfDome.tif --imagery=C:\ Terrain\halfDome_Hillshade.tif --name=HalfDome --outputDir=C:\Terrain\out --heightReference=navd88 --toMetersFactor=1.0 --extensions=".tif" --saveConfig="C:\Terrain\configs\halfdome.json"

Building on the previous example, if you need to rerun the example, such as to build this tileset with attribution strings, you can load from the config.json file.

.\AgTerrain2Tiles.exe --config.json=C:\Terrain\configs\halfdome.json

The AgTerrain2Tiles utility is also capable of processing tilesets in a polar stereographic projection. In the example below, you see how to process and save data representing the lunar south pole using elevation data provided by LOLA.

.\AgTerrain2Tiles.exe --terrain=C:\Terrain\Lunar\LDEM_80S_20MPP_ADJ.tiff --imagery=C:\Imagery\LDEM_80S_20MPP_ADJ_HILL.tiff --name=moon_southpole --outputDir=C:\Terrain\out --heightReference=ellipsoid --toMetersFactor=1.0 --extensions=".tiff" --saveConfig="C:\Terrain\configs\moon_southpole.json"

How To. . .