Create terrain server

Hi folks. I have small home server and many srtm data in tiff format. How i can generate tiles which will be supported by CesiumTerrainProvider ? I read this topic:
May be already exists tools for generation tiles CesiumTerrainProvider format ?

Sorry, bad link(!searchin/cesium-dev/generate$20terrain/cesium-dev/74a5XriE-eM/jns0RsaWetYJ


I generated the current tile set using a simple tool I wrote. The tool loads the source terrain data using GDAL ( and then interpolates heights and writes each tile. Unfortunately, I can’t release the tool, but if you choose to follow a similar path, the format of the Cesium terrain tiles is documented on the wiki ( Please be aware that the format can and will change as time goes on, though if I hear of anyone generating their own data in this format I will make sure to maintain backward compatibility in Cesium.


Thanks for reply.
May be You can help me with algorithm?
I modify gdal2tiles to generate GTiff in Int16 data type.
Now its generate 256x256 tiles. Them i need scale their to 65x65 ? or already gdal2tiles must generate 65x65 tiles ?
PS. Sorry for my english

I modify Now this script generate terrain tiles in cesium format. If somebody needs generate this tile format write me.
Thanks for help.
PS. Cool project. Im very happy what find it =)

Awesome, glad to hear you got it working. I wouldn’t mind taking a look at your modified script, if you don’t mind sharing it.

Hi again. Script for generation terrain tiles for Cesium. Its beta, and in this time have many problems. But its worked.
Whats not realized:
1. Whater mask
2. Aprox height on tile borders
3. Split two and more SRTM files( example: srtm_15_08 and srtm_16_08 result at now looks as
Who knows russian may look this on my site:
Script will be update on this site, changes will be posted in this topic.
Download script:

Cool, thanks for sharing the script with us!

the script link is unavailable now. Could you send me( the script or post it online.

Thanks a lot



gdal2srtmtiles.tar.gz (23.7 KB)
In near feature will be done new version of this file.

Could you provide an example of the command line?


Hi all again. I write new version of script. Download from
Sorry for english, its translate by google )
Original in my native language(russian) and screens may be read on

Whats new:
1. Posted tiles overlap the edges to fit the specification Cesium Terrain Server.
2. Added flag to glue tiles (- join)
3. Laid basic support for water mask
On the second point in more detail. I work with treated SRTM data taken from the server GisLab, this data is based on CGIAR, the only difference is that the mosaic is 5x5 degrees, and the value of NODATA c 255 is replaced by -32678.

So, the flag - join means that the script will first check for the existence of the generated files, and if there are, they will simply supplemented. It used the same script gdal2tiles just overwrite the existing or missing tiles. By the way, this flag can be used to generate raster tiles.
Example, consider two files DEM - srtm_45_04( and srtm_45_05( This two adjacent tile vertically.
For first tile we do --cesium -p geodetic srtm_45_04.tif terrain -z 0-9
We have screen -
For second --cesium -p geodetic srtm_45_05.tif terrain -z 0-9 --join
We have screen -
If you look at what was successful bonding.

With regard to the third point. Now I test your script to process the water mask. For water mask I use lannye SRTM Water Body Data Files (SWBD) that are online HB The algorithm works as follows script as an input parameter the tile DEM (georeferenced), then calculates what the script tiles 1x1 degrees to download The script unpacks the downloaded zip file, rastrizuet them GTiff (input, these tiles have a 1x1 degree shape format), then there is cross-linking of these tiles in a tile 5x5 degrees. When we have the original tile SRTM and ready to grow aquatic mask I do the following I to the basic raster SRTM add another layer (Band) from raster SWBD and generating tiles Cesium Terrain Server when setting a flag - water-mask layer that I will consider the aqueous mask. Has turned out to generate the tile surface with a water mask only for the ground level of tiles, for thumbnail not yet obtained. By the way, SWBD is not only the seas and oceans, but also rivers and lakes.

I am going to use ASTER data. refer to, . Resolution is 30 meters. Is that data compatible to your script?
DEM output format for this data is, GeoTIFF, signed 16 bits, 1m/DN, Referenced to the WSG84/EGM96 geoid, -9999 for void pixels, 0 for sea water body.


I donwload you test tif files and follow your command line. terrain file is created but terrain shapes were not rendered.

try open script and replace NODATA value from -32768 to you value(-9999). May be ist help you. And how many bands in you raster ?

I’ve tried your tiff, and your command line, ./ --cesium -p geodetic srtm_45_04.tif terrain -z 0-9. The output terrain files seem not correct. I zipped my output as attachment . Would you check it? BTW, which distro and version of python-gdal are your use.



terrain.tar.gz (1.62 MB)

I got what my problem is. How did you generate 0/0/0.terrain file? By your script, 0/0/0.terrain will not be created. If this file missing, whole global won't be rendered. When I use cesium team generated 0/0/0.terrain, there would be other issue. cesium team generated 0/0/0.terrain determines it have succeed terrain file in level 1, but I don't copy cesium team generated level 1 terrain file. Error pop up. Did your meet this issue before? What's the full steps to reach your screenshot show terrain?


I forgot to say, in my example srt_45_04 and srtm_45_05 placed in right from 0 degrees by longitude, and terrain in 0 level in left of 0 degrees by longitude not been generated. By specification in terrain place flags which tiles exists on server, in this time i fill this flags as exists. Try do second, generate terrain from tile srtm_45_04(this tile placed in right from 0 degrees by longitude) and second generate terrain from tile srtm_13_06( this tile placed in north america(Los angeles)(left from 0 degrees by longitude) --cesium -z 0-9 -p geodetic srtm_45_04.tif terrain --cesium -z 0-9 -p geodetic srtm_13_06.tif terrain --join
And globe will be rendered full
GDAL 1.8.1, released 2011/07/09
Python 2.7.2
Terrain generated by me from this tiles :
And tile <-> name in globe for google-earth -

Thanks a lot. Your script worked.
And another tiny issue. I don't find "-32768" in script. I cannot replace it with my value, -9999. How to do this modification?