# Create terrain server

**URL:** <https://community.cesium.com/t/create-terrain-server/311>\
**Category:** CesiumJS\
**Created:** [March 9, 2013, 9:23am UTC](https://community.cesium.com/t/create-terrain-server/311 "2013-03-09T09:23:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![s.serge.b](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@s.serge.b](https://community.cesium.com/u/s.serge.b)\
**Post date:** [March 9, 2013, 9:23am UTC](https://community.cesium.com/t/create-terrain-server/311/1 "2013-03-09T09:23:20Z")

</div>

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:  
[http://cesium.agi.com/forum.html?place=msg%2Fcesium-dev%2F74a5XriE-eM%2Fjns0RsaWetYJ](http://cesium.agi.com/forum.html?place=msg%2Fcesium-dev%2F74a5XriE-eM%2Fjns0RsaWetYJ)  
May be already exists tools for generation tiles CesiumTerrainProvider format ?

---

<div class="post-metadata">

**Author:** ![s.serge.b](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@s.serge.b](https://community.cesium.com/u/s.serge.b)\
**Post date:** [March 9, 2013, 10:21am UTC](https://community.cesium.com/t/create-terrain-server/311/2 "2013-03-09T10:21:53Z")

</div>

Sorry, bad link(  
[https://groups.google.com/forum/embed/?place=forum%2Fcesium-dev&showsearch=true&showpopout=true&hideforumtitle=true&parenturl=http%3A%2F%2Fcesium.agi.com%2Fforum.html&afterlogin=#!searchin/cesium-dev/generate$20terrain/cesium-dev/74a5XriE-eM/jns0RsaWetYJ](https://groups.google.com/forum/embed/?place=forum%2Fcesium-dev&showsearch=true&showpopout=true&hideforumtitle=true&parenturl=http%3A%2F%2Fcesium.agi.com%2Fforum.html&afterlogin=#!searchin/cesium-dev/generate%2420terrain/cesium-dev/74a5XriE-eM/jns0RsaWetYJ)

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [March 11, 2013, 2:22pm UTC](https://community.cesium.com/t/create-terrain-server/311/3 "2013-03-11T14:22:04Z")

</div>

Hi,

I generated the current tile set using a simple tool I wrote. The tool loads the source terrain data using GDAL ([http://www.gdal.org/](http://www.gdal.org/)) 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 ([https://github.com/AnalyticalGraphicsInc/cesium/wiki/Cesium-Terrain-Server](https://github.com/AnalyticalGraphicsInc/cesium/wiki/Cesium-Terrain-Server)). 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.

Kevin

---

<div class="post-metadata">

**Author:** ![s.serge.b](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@s.serge.b](https://community.cesium.com/u/s.serge.b)\
**Post date:** [March 11, 2013, 5:33pm UTC](https://community.cesium.com/t/create-terrain-server/311/4 "2013-03-11T17:33:09Z")

</div>

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 ?  
Thanks  
PS. Sorry for my english

---

<div class="post-metadata">

**Author:** ![s.serge.b](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@s.serge.b](https://community.cesium.com/u/s.serge.b)\
**Post date:** [March 12, 2013, 6:59pm UTC](https://community.cesium.com/t/create-terrain-server/311/5 "2013-03-12T18:59:07Z")

</div>

I modify gdal2tiles.py. 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 =)

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [March 12, 2013, 11:31pm UTC](https://community.cesium.com/t/create-terrain-server/311/6 "2013-03-12T23:31:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![s.serge.b](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@s.serge.b](https://community.cesium.com/u/s.serge.b)\
**Post date:** [March 17, 2013, 8:44am UTC](https://community.cesium.com/t/create-terrain-server/311/7 "2013-03-17T08:44:03Z")

</div>

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 [http://sergeserver.dyndns.org/images/cesium/heightfield3.png](http://sergeserver.dyndns.org/images/cesium/heightfield3.png)  
Who knows russian may look this on my site: [http://sergeserver.dyndns.org/index.php/programming/python/2-generator-landshafta-dlya-cesium](http://sergeserver.dyndns.org/index.php/programming/python/2-generator-landshafta-dlya-cesium)  
Script will be update on this site, changes will be posted in this topic.  
Download script: [http://sergeserver.dyndns.org/index.php/downloads/category/1-scripts?download=2:generator-landshafta-dlya-cesium](http://sergeserver.dyndns.org/index.php/downloads/category/1-scripts?download=2:generator-landshafta-dlya-cesium)

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [March 18, 2013, 3:23pm UTC](https://community.cesium.com/t/create-terrain-server/311/8 "2013-03-18T15:23:36Z")

</div>

Cool, thanks for sharing the script with us!

---

<div class="post-metadata">

**Author:** ![researcher\_pim](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@researcher\_pim](https://community.cesium.com/u/researcher_pim)\
**Post date:** [June 14, 2013, 1:33pm UTC](https://community.cesium.com/t/create-terrain-server/311/9 "2013-06-14T13:33:06Z")

</div>

the script link is unavailable now. Could you send me(pim.researcher#[gmail.com](http://gmail.com)) the script or post it online.

Thanks a lot

Shawn

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [June 14, 2013, 1:38pm UTC](https://community.cesium.com/t/create-terrain-server/311/10 "2013-06-14T13:38:45Z")

</div>

Attached.

[gdal2srtmtiles.tar.gz](https://community.cesium.com/uploads/short-url/mepY1HIeYnw56OPdlxowAhtQIR1.gz) (23.7 KB)

---

<div class="post-metadata">

**Author:** ![s.serge.b](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@s.serge.b](https://community.cesium.com/u/s.serge.b)\
**Post date:** [June 14, 2013, 4:55pm UTC](https://community.cesium.com/t/create-terrain-server/311/11 "2013-06-14T16:55:36Z")

</div>

[http://sergeserver.dyndns.org/index.php/downloads/category/1-scripts?download=1:gdal2tilessrtm](http://sergeserver.dyndns.org/index.php/downloads/category/1-scripts?download=1:gdal2tilessrtm)  
In near feature will be done new version of this file.

---

<div class="post-metadata">

**Author:** ![researcher\_pim](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@researcher\_pim](https://community.cesium.com/u/researcher_pim)\
**Post date:** [July 18, 2013, 2:24pm UTC](https://community.cesium.com/t/create-terrain-server/311/12 "2013-07-18T14:24:22Z")

</div>

Could you provide an example of the command line?

Thanks,  
Shawn

---

<div class="post-metadata">

**Author:** ![s.serge.b](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@s.serge.b](https://community.cesium.com/u/s.serge.b)\
**Post date:** [July 18, 2013, 4:36pm UTC](https://community.cesium.com/t/create-terrain-server/311/13 "2013-07-18T16:36:57Z")

</div>

Hi all again. I write new version of script. Download from [http://sergeserver.dyndns.org/index.php/downloads/category/1-scripts?download=2:gdal2srtmtiles-with-join-option](http://sergeserver.dyndns.org/index.php/downloads/category/1-scripts?download=2:gdal2srtmtiles-with-join-option)  
Sorry for english, its translate by google )  
Original in my native language(russian) and screens may be read on [http://sergeserver.dyndns.org/index.php/programming/python/4-generator-landshafta-dlya-cesium-versiya-ii](http://sergeserver.dyndns.org/index.php/programming/python/4-generator-landshafta-dlya-cesium-versiya-ii)

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([http://gis-lab.info/data/srtm-tif/srtm\_45\_04.zip](http://gis-lab.info/data/srtm-tif/srtm_45_04.zip)) and srtm\_45\_05([http://gis-lab.info/data/srtm-tif/srtm\_45\_05.zip](http://gis-lab.info/data/srtm-tif/srtm_45_05.zip)). This two adjacent tile vertically.  
For first tile we do gdal2srtmtiles.py --cesium -p geodetic srtm\_45\_04.tif terrain -z 0-9  
We have screen - [http://sergeserver.dyndns.org/images/cesium/srtm\_45\_04.png](http://sergeserver.dyndns.org/images/cesium/srtm_45_04.png)  
For second gdal2srtmtiles.py --cesium -p geodetic srtm\_45\_05.tif terrain -z 0-9 --join  
We have screen - [http://sergeserver.dyndns.org/images/cesium/srtm\_45\_05.png](http://sergeserver.dyndns.org/images/cesium/srtm_45_05.png)  
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 [http://dds.cr.usgs.gov/srtm/version2\_1/SWBD/](http://dds.cr.usgs.gov/srtm/version2_1/SWBD/). The algorithm works as follows script as an input parameter the tile DEM (georeferenced), then calculates what the script tiles 1x1 degrees to download [http://dds.cr.usgs.gov/srtm/version2\_1/SWBD/](http://dds.cr.usgs.gov/srtm/version2_1/SWBD/). 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.

[http://sergeserver.dyndns.org/images/cesium/stm\_45\_04-sea.png](http://sergeserver.dyndns.org/images/cesium/stm_45_04-sea.png)  
[http://sergeserver.dyndns.org/images/cesium/sertm\_45\_04-lake.png](http://sergeserver.dyndns.org/images/cesium/sertm_45_04-lake.png)

---

<div class="post-metadata">

**Author:** ![researcher\_pim](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@researcher\_pim](https://community.cesium.com/u/researcher_pim)\
**Post date:** [July 19, 2013, 12:41pm UTC](https://community.cesium.com/t/create-terrain-server/311/14 "2013-07-19T12:41:19Z")

</div>

Hi,  
I am going to use ASTER data. refer to, [http://gdem.ersdac.jspacesystems.or.jp/search.jsp](http://gdem.ersdac.jspacesystems.or.jp/search.jsp) . 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.

Thanks,  
Shawn

---

<div class="post-metadata">

**Author:** ![researcher\_pim](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@researcher\_pim](https://community.cesium.com/u/researcher_pim)\
**Post date:** [July 20, 2013, 12:11pm UTC](https://community.cesium.com/t/create-terrain-server/311/15 "2013-07-20T12:11:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![s.serge.b](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@s.serge.b](https://community.cesium.com/u/s.serge.b)\
**Post date:** [July 20, 2013, 1:12pm UTC](https://community.cesium.com/t/create-terrain-server/311/16 "2013-07-20T13:12:18Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![researcher\_pim](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@researcher\_pim](https://community.cesium.com/u/researcher_pim)\
**Post date:** [July 20, 2013, 1:33pm UTC](https://community.cesium.com/t/create-terrain-server/311/17 "2013-07-20T13:33:30Z")

</div>

I’ve tried your tiff [http://gis-lab.info/data/srtm-tif/srtm\_45\_04.zip](http://gis-lab.info/data/srtm-tif/srtm_45_04.zip), and your command line, ./gdal2srtmtiles.py --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.

Thanks,

Shawn

[terrain.tar.gz](https://community.cesium.com/uploads/short-url/clAX2PPIE7rSRhpLUn9dRMi9nO0.gz) (1.62 MB)

---

<div class="post-metadata">

**Author:** ![researcher\_pim](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@researcher\_pim](https://community.cesium.com/u/researcher_pim)\
**Post date:** [July 20, 2013, 2:53pm UTC](https://community.cesium.com/t/create-terrain-server/311/18 "2013-07-20T14:53:00Z")

</div>

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?

Thanks,  
Shawn

---

<div class="post-metadata">

**Author:** ![s.serge.b](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@s.serge.b](https://community.cesium.com/u/s.serge.b)\
**Post date:** [July 20, 2013, 3:17pm UTC](https://community.cesium.com/t/create-terrain-server/311/19 "2013-07-20T15:17:58Z")

</div>

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)  
gdal2srtmtiles.py --cesium -z 0-9 -p geodetic srtm\_45\_04.tif terrain  
gdal2srtmtiles.py --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 : [http://sergeserver.dyndns.org/phocadownload/terrain.tar.gz](http://sergeserver.dyndns.org/phocadownload/terrain.tar.gz)  
And tile \<-\> name in globe for google-earth - [http://sergeserver.dyndns.org/phocadownload/srtm41.kmz](http://sergeserver.dyndns.org/phocadownload/srtm41.kmz)

---

<div class="post-metadata">

**Author:** ![researcher\_pim](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@researcher\_pim](https://community.cesium.com/u/researcher_pim)\
**Post date:** [July 22, 2013, 3:30pm UTC](https://community.cesium.com/t/create-terrain-server/311/20 "2013-07-22T15:30:28Z")

</div>

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?

Thanks,  
Shawn

[Next page](https://community.cesium.com/t/create-terrain-server/311.md?page=2)
