Dem2stl
Converts a Digital Elevation Model (DEM) raster surface to the STereoLithography (STL) format using the GDAL library
Install / Use
/learn @cvr/Dem2stlREADME
dem2stl
Converts a Digital Elevation Model (DEM) topography surface to the STereoLithography (STL) format using the GDAL library.
Summary
The dem2stl.py python script converts a Digital Elevation Model (DEM) (such as GeoTIFF) to a STereoLithography (STL) file. The result is a topography surface that may be used to generate computational grids such as those required by OpenFOAM meshing programs.
The dem2stl.py script can cope with DEM raster files referenced to geographic coordinates (longitude and latitude), internally projecting into an UTM coordinate system using Proj4.
Example
The following example uses the GeoTIFF sample file GeogToWGS84GeoKey5.tif:
./dem2stl.py example/GeogToWGS84GeoKey5.tif example/GeogToWGS84GeoKey5.stl
The GeogToWGS84GeoKey5.stl output file
may be viewed using meshlab:

Usage
usage: dem2stl.py [-h] [-v] [--band BAND] RASTER STL
Convert a GDAL raster (like a GeoTIFF heightmap) to an STL terrain surface.
positional arguments:
RASTER Input GeoTIFF image
STL Output STL path
optional arguments:
-h, --help show this help message and exit
-v, --verbose Print log messages
--band BAND Raster data band, defaults to 1
Requirements to run
The following python modules are required to run
dem2stl.py:
On Debian-based systems these modules may be installed running:
apt-get install libpython2.7-stdlib libpython2.7-minimal \
python-numpy python-gdal python-pyproj
Acknowledgments
dem2stl.py was based from the following
python scripts:
phstl.pyby Jim DeVona (MIT License, commit id5717d88, 2016-11-09).- The computation of the UTM zone was based on
LatLongUTMconversion.pyby Han Ul Yoon (acessed 2017-05-12).
