Converts a Digital Elevation Model (DEM) topography surface to the STereoLithography (STL) format using the GDAL library.
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.
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: 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
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
dem2stl.py
was based from the following
python scripts:
phstl.py
by Jim DeVona (MIT License, commit id5717d88
, 2016-11-09).- The computation of the UTM zone was based on
LatLongUTMconversion.py
by Han Ul Yoon (acessed 2017-05-12).