Code example to create heightmap .terrain file


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.


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 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 See here:

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, 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.