Code example to create heightmap .terrain file

Hi,

I have some .dem files. Is there any code example for how to create .terrain file from .dem. Or, any key word to search about this.I'v tried GDAL tools. It seems hard to create by GDAL tools.

Regards,
Shawn

I got some hints. Use MapTiler to get gray scale png images. Then translate these images to .terrain file. But I have problem, how to create water area?

I generated the tiles on cesium.agi.com using the GDAL API and some custom code which I unfortunately can’t share. A user awhile back had some success generating tiles using a modified version of gdal2tiles.py. See here:

https://groups.google.com/d/msg/cesium-dev/rBieaEBJHiU/qv1n5u3n5xcJ

As for the water mask, you can just add one byte (a zero), and the entire world will be treated like land. In the terrain dataset on cesium.agi.com, we deduce the water areas from the voids in our source data. Anywhere the source data has a void (no data), we treat like water. This isn’t perfect, but it works reasonably well.

Kevin