Wednesday, 7 September 2016

Creating a TIN from a raster DEM

NB! This blog post will constantly change until I find a good open source solution to create a Triangulated Irregular Network (TIN) from a Digital Elevation Model (DEM). Would you like to help? Please add a comment below!

NEW! Read the first test of the TIN capabilities of SAGA GIS.

People have already helped on Twitter, and I'll include some of these suggestions in this post.

My example DEM of Jotunheimen in Norway can be downloaded here (144 MB GeoTIFF). This is the same dataset I've used previously for my terrain mapping experiments with three.js and Cesium.



The goal now is to turn this raster DEM into a nice triangulated irregular network (TIN) optimised for 3D rendering. 

The dream solution would be a command line tool (part of GDAL?) that can turn a raster DEM into an optimised TIN.

Open source candidates: 


GIS StackExchange

Commercial tools: 

9 comments:

Grognon said...

I would convert the to a xyz file, load it in a tool like cloudcompare and mesh it there. CC offers both TIN and Poisson reconstruction.

Brad Hards said...

If you are looking for something with a Cesium flavour, it might be worth checking https://quantized-mesh-tile.readthedocs.io/en/latest/ and the code at https://github.com/loicgasser/quantized-mesh-tile

I haven't tried it - its roughly half way down my todo list for this decade...

Bjørn Sandvik said...

Grognon, I'll definately have a closer look at CloudCompare. It was able to open my 10 m DEM file without a problem, but still need to figure out how to create a TIN.

Brad, yes I'm aware of this project - and I want to move in this direction. This is the missing part of this workflow: https://github.com/geoadmin/3d-forge/issues/168

Unknown said...

You can execute SAGA algorithms with SAGA CMD:

https://sourceforge.net/p/saga-gis/wiki/Executing%20Modules%20with%20SAGA%20CMD/

Unknown said...

Bjorn, Another option to consider is Whitebox by Dr John Lindsay http://www.uoguelph.ca/~hydrogeo/Whitebox/

Unknown said...

Recent work on 3dfier from the 3D Geoinformation group at Delft University, The Netherlands may be of interest: https://3d.bk.tudelft.nl/news/2016/09/08/3dfier-awesome-video.html

Rowan Blaik said...

Hi Bjorn,

Try the following with GDAL and Meshlab:

gdal_translate -of XYZ jotunheimen_100m.grd jotunheimen_100m.asc

meshlabserver -i jotunheimen_100m.asc -o jotunheimen_100m.ply -s filter-script.mlx

The filter-script.mlx file is a Meshlab script made with the GUI as here - http://www.andrewhazelden.com/blog/2012/04/automate-your-meshlab-workflow-with-mlx-filter-scripts/

I included two filters in my script: "invert face normals" and "Quadratic Edge Collapse Decimation". I set the decimation to 175,000 faces with every with every option on except "weighted simplification" and "simplify only selected faces". The results look much better than what SAGA achieved, with flat low-poly water bodies.

Rowan

Snomi said...
This comment has been removed by the author.
Snomi said...

@Rowan

I have managed to apply your steps, stepping the quality on the simplification filter up to 1.0 means I get a really nice TIN. Thanks!

Now for the conversion to Quantized Mesh it still needs to be tiled. I was thinking changing gdal2tiles to use .asc xyz, and then feed each tile into meshlab. After this use the Quantized Mesh Tile python library.

The library only takes WKT input so the .ply from meshlab just needs to be re-ordered, but that adds an extra conversion step.

Any thoughts?