Cesium Terrain Builder Docker
This repo contains a
Dockerfile for the Cesum Terrain Builder (CTB) app with support for the new Cesium terrain format quantized-mesh. It is build from a fork providing quantized-mesh support, as described in this artice.
Thanks to @homme and @ahuarte47 for the great work on Cesium Terrain Builder and quantized-mesh support.
The Docker image is available on DockerHub from tumgis. To get the image run:
docker pull tumgis/ctb-quantized-mesh
Note: The images are rebuild on every push to ahuarte47/cesium-terrain-builder/tree/master-quantized-mesh. Goto hub.docker.com/r/tumgis/ctb-quantized-mesh to check for the latest build.
Follow the steps below to create your own quantized-mesh tiles for Cesium using this Docker image:
- Cesium Terrain Builder usage
The system ressources Docker can use are limited by default on Windows systems. Goto Docker tray Icon -> Settings -> Advanced to adjust the number of cores and main memory Docker can use to increase performance.
It is highly recommended (but not required) to transform your data to the WGS84 (EPSG:4326) coordinate reference system before using CTB. This helps to avoid vertial or horizontal offsets of terrain datasets.
NTv2 transformation method if available. This is e.g. supported by FME using the
EsriReprojector transformer or ESRI ArcGIS.
Put your data in a folder, that can be mounted by Docker. On Windows, you will have to grant access to the drive where the data is located before being able to mount the folder. Goto Docker tray Icon -> Settings -> Shared Drives to share drives with Docker. Visit this blog post for a comprehensive guide on mounting host directories on Windows.
In the following we assume that your terrain data is stored in
d:\docker\terrain for a Windows Docker host and drive
d:\ is shared with Docker. For a Linux Docker host we assume your data is stored in
Cesium Terrain Builder usage
When your data is transformed and copied to a location available for Docker your are ready for creating a Cesium terrain with CTB.
Start CTB container and mount data folder
First, start a CTB container and mount your terrain data folder to
/data in the container. Follow the examples below for different operating systems and shells.
docker run -it --name ctb \ -v "/docker/terrain":"/data" \ tumgis/ctb-quantized-mesh
docker run -it --name ctb ^ -v "d:/docker/terrain":"/data" ^ tumgis/ctb-quantized-mesh
winpty docker run --rm -it --name ctb \ -v "d:\\docker\\terrain":"/data" \ tumgis/ctb-quantized-mesh
Create a GDAL Virtual Dataset (optional)
If you dataset consists of a single file, continue to the next step. If your dataset consists of multiple tiles (more than one file), a GDAL Virtual Dataset needs to be created using the
gdalbuildvrt <output-vrt-file.vrt> <files>
For instance, if you have several
*.tif files, run:
gdalbuildvrt tiles.vrt *.tif
More options to create a GDAL Virtual Dataset e.g. using a list of files are described in the gdalbuildvrt documentation.
Create Cesium Terrain files
First, create an output folder for you terrain, e.g.
mkdir -p terrain. Second, run CTB to create the terrain files:
ctb-tile -f Mesh -C -N -o terrain <inputfile.tif or input.vrt>
For example, if a
tile.vrt has been created as described above:
ctb-tile -f Mesh -C -N -o terrain tile.vrt
ctb-tile app supports several options. Run
ctb-tile --help to display all options. For larger datasets consider setting the
-m option and the
GDAL_CHACHEMAX environment variable as described here.
Create Cesium layer description file
Finally, a layer description file needs to be created. Simply run the same command you used for creating the terrain files again adding the
-l switch. For instance:
ctb-tile -f Mesh -C -N -o terrain tiles.vrt # Create terrain files ctb-tile -f Mesh -C -N -l -o terrain tiles.vrt # Create layer description file
Finally, your terrain data folder should look similar to this:
$ tree -v -C -L 1 terrain/ terrain/ |-- 0 |-- 1 |-- 2 |-- 3 |-- 4 |-- 5 |-- 6 |-- 7 |-- 8 |-- 9 |-- 10 |-- 11 |-- 12 |-- 13 |-- 14 |-- 15 `-- layer.json
The quantized-mesh terrain is now ready for usage.