Are there any tools that can take a DTM, in asc or geotiff format and generate a mesh from this that can used in meshlab or similar software.
I have asc DTM file that I need to convert to a ply mesh file. Is this possible?
In response to the comment. Then these DTM asc files are not the ones that meshlab understands.
The files starts with:
ncols 6250
nrows 6250
xllcorner 630000.000000000000
yllcorner 6070000.000000000000
cellsize 1.600000000000
NODATA_value -9999
Best Answer
A DTM raster can be represented by triangle meshes by finding a set of non-overlapping triangles that covers the entire mesh and approximates the elevation field. There are two different types of triangle meshes that can be used for this purpose:
In most applications, if you need to deal with elevation meshes, you'd go with a TIN since throwing out redundant or nearly redundant information allows for more efficient computations. However, creating TINs from rasters isn't straightforward, since there are many different triangulations that approximate a grid with the same error, but using different vertex sets.
Software for creating TINs
Raster to TIN
function from the 3D Analyst toolbox.Grid to TIN (Surface Specific Points)
function, followed byExport TIN to Stereo Lithography File (STL)
function to export the TIN to a mesh format readable by Meshlab.Software for creating TRNs
Grid to TIN
function.Roll your own solution: Implementing it isn't particularly hard. Here's a Python script that uses the GDAL library to read a raster DTM, and then writes out a binary PLY mesh.
Save the script as
gdal_rastertotrn.py
, then call it usingpython gdal_rastertotrn.py <inputraster> <outputply>
.Here's an example. Converting a raster DTM of Crater Lake called
crater_lake.tif
...... by calling
python gdal_rastertotrn.py crater_lake.tif crater_lake.ply
, and opening the resultingcrater_lake.ply
in Meshlab:Here's the (unpolished) script. Since it uses the GDAL library, it can convert all raster types supported by GDAL. It only writes PLY files.