3D printing of digital elevation models

From EduTech Wiki
Jump to: navigation, search

1 Printing elevation models

Isola di Vulcano - PLA, 25x20cm, green PLA, printed in about 16h

Physical terrain models can be made with various technologies. 3D printing is a good choice for smaller models. For larger models we suggest stacking plates cut with a laser cutter or another tool. Milling is another option, but noisier and more dusty than 3D printing. Printed elevation models are useful in teaching, outreach activities, informal learning settings like museums, tourist offices, urban planning, etc.

This article describes how to create printable STL models with (mostly) free tools from various kinds of free terrain data (digital elevation models, DEM). Producing STL models from terrain data can be similar to producing models from 3D scans since some digital elevation models (DEMs) also use point clouds. This text is under construction and may need re-organizing. For the moment, I just take down notes of what I am playing with. So far, I identified several ways to create digital elevation models that work.

  • The easiest solution is Terrain2STL. It takes 90m squares from anywhere in the world. That is a good resolution for models of larger areas, but not good enough for precision models of smaller mountains.
  • The most powerful and versatile tool combination is probably using QGIS and the Demto3D plugin.
Lake Geneva - Mont Blanc area - White PLA, 19x16.5cm, printed in 11h26m

1.1 Typical workflow

The outline of the workflow is the following (some tools allow combining steps, in some situations steps are done in different order or differently)

  1. Get a model. This usually requires some extraction work, e.g. download a file, extract a square from given coordinate position
  2. Transform the model to a 3D model (digital elevation models usually are not 3D models)
  3. Make the model manifolded with a flat bottom.
  4. Scale, rotate and re-position (if necessary)
  5. Translate this model to STL.
  6. Repair the model with an STL editor, e.g. use Netfabb (repair tool) or Meshmixer ("make solid")
  7. If the model represents a very small area you can slice it "as is". If it is larger, consider reducing the triangles (if not done before), e.g. using the free Meshlab program to do that (see below)
  8. Crop x,y direction if there is a need. Add a box to the bottom if there is a need.
  9. Adjust the Z-axis (if not done before). In some cases you might want to emphasize horizontal distances by a factor of 2, 3 or 4.
  10. Slice and print it. This is not as easy as it seems and for two reasons. Models can be huge and slicer settings must be adapted to avoid print aborts (in particular nozzle getting stuck in plastic).

Too much for you ?

3D printing too slow ?

1.2 Digital elevation model formats

A digital elevation model (DEM) is a digital representation of a terrain surface that is created from elevation data. There are two kinds:

  • Digital terrain models (DTM) include just the terrain
  • Digital surface models (DSM) include things on top, like buildings).

It is not clear (to us) whether radar models that measure the tips of trees and houses are DTMs or DSMs.

There are many formats used. Difference in horizontal resolution can be important. E.g. SwissALTI3D is only 2m meters, Eu-DEM is 25 meters, free SRTM data is between 30 and 90 meters. A resolution of 90 meters is fine enough for a larger area, e.g. 100x100km. Printing nicely smaller mountains requires 30 meter resolution. There exist errors for height (usually expressed in terms of mean errors).

Wikipedia has a good GIS file formats list that includes formats that can include DEM data. Acording to Wikipedia's Digital elevation model article, DEM can be represented as a raster (a grid of squares, also known as a heightmap when representing elevation) or as a vector-based triangular irregular network (TIN).

  • According to Wikipedia (March 2017), Raster data consists of rows and columns of cells, with each cell storing a single value. Raster data can be raster images with each pixel (or cell) containing a color value. Additional values recorded for each cell may be a discrete value, such as land use, a continuous value, such as temperature, or a null value if no data is available. While a raster cell stores a single value, it can be extended by using raster bands to represent RGB (red, green, blue) colors, colormaps (a mapping between a thematic code and RGB value), or an extended attribute table with one row for each unique cell value.
  • Again, according to Wikipedia's GIS file formats article, there are three types of vector graphic elements: points (to represent precise location spots), lines (to represent roads, rivers, etc.) and polygons. Elevation can be represented either by contour lines or by polygone meshes, usually triangulated irregular networks (TINs)s. “A TIN is a vector-based representation of the physical land surface or sea bottom, made up of irregularly distributed nodes and lines with three-dimensional coordinates (x, y, and z) that are arranged in a network of nonoverlapping triangles.”.

Below we just the list most of the the data types we played with and that appear in this article

Name File extension Description Data type
ESRI ASCII GRID asc A popular GIS specific exchange format. See Esri grid (wikipedia) raster
geoTIFF tif or tiff Annotations to the 2D TIFF format. See GeoTIFF (Wikipedia) raster (grid)
DXF dxf Autocad proprietary but many tools can import/export vector
XYZ xyz Initially designed to describe molecule geometry. vector (point clouds, each point has a x/y/z coordinate and there are no links between points)
SRTM HGT hgt SRTM original format raster
DEM dem geospatial file format developed by the United States Geological Survey raster
Collada dae 3D models used withing Keyhole Markup Language (KML), Google Earth vector
GeoJSON json Popular exchange format for open source GIS packages vector

1.3 Digital elevation model (DEM) repositories

Most DEM data that is freely available on a world-wide basis has been collected by the NASA Shuttle Radar Topography Mission (SRTM) in 2000. It took 11 days to map out the Earth (except the seas and polar regions). Resolution of SRTM data is the following:

  • 30 arc seconds (DTED level 0) - about 900 m spacing
  • 3 arc seconds (DTED level 1) - about 90 meters spacing
  • 1 arc second (DTED level 2) - about 30 meters spacing

There are many other DEM data sets (primary or secondary) world-wide or on a national or local basis. Several of these data sets make use of the SRTM data set. A good list of available SRTM data sets is in the OpenStreetMap Wiki SRTM article.

Below are a few DEM repositories. Most of these require some "thinking" before you actually can get at the data.

Name Resolution (x/y axis) Mean errors (z)

depend on slope

Data Source
CGIAR-CSI SRTM 90m Allows finding and exporting squares with 90 resolution for the whole earth.
USGS EROS (US Geological survey) - EarthExplorer 30 to 90m Various, e.g. SRTM The Earthexplorer allows finding map squares according to area and criteris, e.g. I found 30m resolution SRTM data for Geneva ara. Since the tiles cover small areas you may have to combine these.
ViewFinderPanoramas (VFP) 30.92m SRTM and ASTER GDEM
EU-DEM 30.92m
EOWeb Poral (DE)
DHM25 25m 2-8m Swisstopo Prior to SwissALTI3D, based in essence on the 1:25000 maps. This data set is free
SwissALTI3D 2m Swisstopo commercial dataset

2 Using Terrain2STL oneline service to produce STL from 90m SRTM dataset

This method describes the the easiest and fastest way to get going. Any beginner with a moderate amount of 3D mesh manipulation skills can do it.

Terrain2STL is an online service that allows selecting a square on Google maps. From these coordinates it then will extract a region from the Nasa/cgiar-csi data and produce the STL. Quote: “Terrain2STL is a free-to-use service, but if you want to help support the site, donations are welcome. Terrain2STL creates STL files using the SRTM3 dataset from 2000, which has a resolution of about 90 meters on the equator.” (Terrain2STL home page, feb 2017)

It only will need some cropping and a little repair, e.g. something that Netfabb Studio can handle very well.

I tested this service and it works really well, e.g. I printed the Teide and Caldera Blanca volcanoes. The only caveat is the 90m resolution of the SRTM3 data set. The Caldera Blanca is a small 300m mountain on Lanzarote and did not come out in a very interesting way. The Teide (including its old huge caldera) created a fine enough model.

In case you want some more control, and if you own a Linux system, you can use the hill program below which provides the same kind of results. While figuring out the coordinates and dimensions of your map takes more time, producing it is faster.

Finally, you should be aware that printing 3D models may require different slicer settings than the one you typically use. See below.

3 Produce STL from ASC SRTM data with the hills command line tool

Hills is a command line package that can generate 3D models of areas in STL format of the earth's surface using SRTM 90m elevation data from CGIAR-CSI (see http://srtm.csi.cgiar.org/).

This command line tool is programmed in Haskel and requires some installation work. If you are not afraid of typing instructions, it's an easy to use tool. It can directly extract the right squares before doing the STL translation.

3.1 Installation under Ubuntu

To install Haskel and cabal

sudo apt install cabal-install

To install hills:

cabal update
cabal install hills

I found the program in ~/.cabal/bin/ so you might add this to your path:

  • Edit ~/.bashrc
  • Prepend /home/your_login/.cabal/bin to :$PATH, e.g.
export PATH=/home/_____/.cabal/bin:$PATH

3.2 Using hills to create printable STL terrain models

This method works with the dataset and tools described below. I did manage to create fairly quickly a decent STL model of the Geneva basin area - Daniel K. Schneider (talk) 16:41, 3 March 2017 (CET)

Get a data file from CGIAR-CSI. The earth is divided into squares. Make sure to take the ESRI ASCII (*.ASC version !).

SRTM Data Search allows to identify squares that you then can dowload
  • Either use the website where you can select the squares (see figure above)
  • Or write down the square number and change the URL below. 38_03 represents parts of Western Switzerland, French Haute-Savoie etc. (are where University of Geneva is located)
wget http://srtm.csi.cgiar.org/SRT-ZIP/SRTM_v41/SRTM_Data_ArcASCII/srtm_38_03.zip
unzip srtm_36_01.zip

You now should have the following 150 GB file

150147952 Nov 24  2008 srtm_38_03.asc

From there you can extract rectangles that will be translated to STL models. You need the following information:

Get center coordinates

  • Coordinates of the center, defined as decimal latitudes and longitudes. North of the equator is positive, south is negative. East from Greenwich is positive, west is negative. A good trick is to ask Google. E.g. longitude Geneva gives:
46.2044° N, 6.1432° E

Exactly what we need to extract terrain around Geneva. If you cannot retrieve this directly from google search, you could use google maps or google earth and then click on a point. E.g. my office building is around:

46.194644, 6.140955

Define rectangle size

  • Hills requires an area in arc seconds, latitude first. Default values are 300x600. An arc second is 1/3600 of a degree and roughly represents 30 meters (it depends where you are). Therefore:
1km = 33
10km = 330

Since any decent STL tool allows you to cut away slices, you do not need to be very precise. Better take 50% extra terrain.

Define elevation

  • By default, the model will start a sea level. Again, you easily could not define any elevation and just cut off a slice in the z-direction. But you may consider giving a height. Again, you simply can ask google, e.g. elevation geneva. Add enough height to cover the lowest point of your area.

Define scale

  • By default, an area of 30x30km will come out much too big. You can change the size later, but by using the scale parameter you can make it smaller.
500 will reduce it by 1:500

Example using the three parameters described just above. By default, hills will look at all the *.asc files that sit in the same directory.

hills --position 46.194,6.140 --dimensions 600x600 --base-altitude 300 --scale 1000 geneva.stl

generating for

 46-6-36N 6-3-24E to 46-16-39N 6-13-24E
 603 arcsec N/S x 600 arcsec E/W
 18.618km N/S x 12.865km E/W

Here is the result as seen in Meshlab:

Geneva terrain model made with hills and SRTM data

A second, better attempt that covered the whole was:

 hills --position 46.194,6.140 --dimensions 1200x2400 --base-altitude 200 --scale 250 geneva-large.stl
Geneva terrain model being cropped in Netfabb

The following will create a (roughly) 99 x 114 km area of the Geneva Lake - Mont Blanc area. Initially I extracted at base-altitude of 150m, but that was not low enough for such a large area.

hills --position 46.138,6.459 --dimensions 3200x5300 --base-altitude 0 --scale 600 geneve-mont-blanc.stl
generating for 
 45-41-36N 5-43-21E to 46-34-57N 7-11-42E
 3201 arcsec N/S x 5301 arcsec E/W
 98.834km N/S x 113.781km E/W

For faster slicing and easier manipulation, you should reduce triangles, e.g. with Meshlab (see below)

Slicing of the Geneva Lake Mont-Blanc Area (6 minutes)

4 Converting DEM files with AccuTrans

AccuTrans is a cheap commercial DEM file manipulation program. It can important various DEM formats in various ways, create a 3D model and add a bottom and, finally, export to STL.

  • Download the software from http://www.micromouse.ca/. It is free for one month. After that you should pay CAN 20$, which is very cheap for what you get. In particular, the possibility to add a box to the bottom of non 3D DEM model makes this tool a must have.
  • Hit F3 to select another layout (e.g. large window)

Initally, I tested the free 25m/200m resolution files from SwissTopo, i.e. fairly huge files. The dxf is 358 MB.

358870706 Jul 1 2010 DHM200_polyface.dxf
41714539 Mar 26 2010 DHM200.xyz
18153345 Mar 15 2010 DHM200.asc
  • It did read the ASC file and convert it to STL. However it is fairly low resolution (1926x1201 cols for Switzerland. Plenty enough for printing the whole thing, but not smaller parts). the exported STL was 14MB.
  • It did only load parts of the dxf (complained about a line that is long for a buffer)
  • It did manage to load the xyz file (41MB). Displaying it was straining the CPU and/or GPU). The exported STL was 146MB and (10 times bigger than the one produced from the *.asc) left-right inverted.

Extracting areas from these monster models can be challenging for some computers. You also could use one of few "educational models". E.g.Swiss topo provides two sample data (one is the model available as thing 26746.

I also use AccuTrans to process Collada (*.dae) files extracted from OpenStreetMap with Maperitive

4.1 Dealing with Autodesk dxf files

The steps for converting dxf files are described in Relief für den 3D-Druck aus DHM oder DEM erstellen are the following:

(1) Load the model

  • File -> Open (New) or Open (All Formats)
  • ... wait

(2) Make it a 3D model

  • Tools->Extrude Pseudo 2D surface

(2) Scale (this is optional)

  • Tools_1 -> Adjust object parameters
    • Click on Calculate scale. Select the larger x or y value, then enter a desired result, e.g. 200 because your printer will want millimeters and your print bed is not much bigger than that. You always can fine tune in the STL editor.
    • Hit the scale button
    • Tick Set Min at 0.0.0
    • Click OK at the bottom.

(3) Add a bottom

  • Tools->Extrude Pseudo 2D surface
    • Tick "Flat Bottom"
    • Add thickness, e.g. 50000 for the Swiss top map, 1000 for a model that varies from Z=192 and 4556 (Mont Blanc), or 0,5 for a small model
    • Click on Extrude
    • ... wait if your file is large

(4) Rotate the model (optional)

  • Rotation can be wrong (y axis should point down, i.e. Blender style)
    • Click on Adjust Object icon
    • Rotate 90 degs on the X axis. You now should see the model from the top. Click on the 90 button in the Rotate panel

(5) Export as STL.

  • Save as, select STL
  • The orginal *.dxf from Swiss Top was about 359 MB. The STL was 467 MB and included 4'643'020 vertices (points) and 9'345'628 faces. Now that is large file but Meshlab could handle in on my old Ubuntu machine with a low end Quadro card. Same for my older Dell XPS 17 with an old Nvidia mobile card.

(6) Decimate triangles if your file is big

  • Your printer cannot print 10 million faces. So, either select an area for printing and crop the STL or reduce the triangles (see below for triangle reduction in Meshlab).
  • After reducing it down to 5% the file became more manageable.

(6b, alternative)

  • Load the STL file in an STL editor that allows slicing, e.g. Netfabb
  • Cut out your area.
  • My very old Precision workstation I use for controlling the 3D printer was able to handle the 500MB file, but just barely...

(7) Repair and scale the file in an STL editor

  • Repair is needed, the file does have bad mesh problems,
  • Scale to right x,y size
  • Augment (optionally) Z, e.g. to 200%
  • Repair again, save,

The resulting file had about 440K triangles which is maybe reasonable. ... slice and print

4.2 Dealing with ArcInfo ASCII grid (*.asc) files

(1) Open the file

  • Important do not just load the file, but click on "open", select ArcInfo ASCII Grid, then select the file. Since *.asc also can refer to another format you will have to do it this way !
  • Click on OK

(2) Make it a 3D model (maybe there is another way)

  • Menu Dem->Create 3D model
  • Menu Tools_1 -> Extract pseudo 2D surface
    • In the dialog, tick Flat Bottom and add a thickness, e.g. 1000 for a model of Switzerland (look at Z min and Z max). In the Swiss case this will add 1000 meters underneath, i.e. a fifth of the highest peak (in Italy), i.e. about 2mm in the printed model (dependent on how it will be scaled)
AccuTrans3D - *.asc model seen from the bottom - it's not printable like that
AccuTrans3D - After transforming an *.asc model to a 3D model with a flat bottom added

(3) Save as STL

  • Save as STL
  • Use an STL editor to clean the mesh and to clip if necessary.

4.3 Using XYZ files

(1) Open the XYZ file

  • Select "Probe Scan" (for the Swiss Top files)
  • Scale Z coordinates if you like
  • Tick OK

... wait

(2) Convert to 2D structure

  • See above

... to be continued.

4.4 Using *.dae files

Collada (*.dae) is used by Google earth and is used by Sketchup as exchange format.

Read OpenStreetMap, the chapter on Maperitive, 3D printing section.

The procedure is the same as for *.dxf files (+/- some little details).

5 Creating STL from OpenStreetMap data

This is described in Maperitive for laser cutting and 3D printing. The procure described takes more time and uses the same data, i.e. at some point in the prodecure you will retrieve the same type of STRM data and then pass the model to AccuTrans (see previous section).

Using OpenStreeMap is only a good option, if plan to "annotate" the 3D model with other information. E.g. print lakes, streets or boundaries with a another color (double print head required). You also can imagine to alter the geometry, e.g. extrude walls.

6 Using QGIS and the GDAL library

QGIS is a free GIS tool and its DEMto3D plugin allows to produce printable STL files. GDAL is a raster manipulation library that you could use standalone via command line instructions or through the "Raster" menu in QGIS.

Since people most interested in elevation data are geographers, it is good idea to become somewhat familiar with a toolsets that allow manipulating various kinds of raw digital terrain formats and maps.

QGIS is a GIS program to "Create, edit, visualise, analyse and publish geospatial information on Windows, Mac, Linux, BSD (Android coming soon)". According to Wikipedia, “Similar to other software GIS systems, QGIS allows users to create maps with many layers using different map projections. Maps can be assembled in different formats and for different uses. QGIS allows maps to be composed of raster or vector layers. Typical for this kind of software, the vector data is stored as either point, line, or polygon-feature. Different kinds of raster images are supported, and the software can georeference images.”

GDAL is a “ translator library for raster and vector geospatial data formats that is released under an X/MIT style Open Source license by the Open Source Geospatial Foundation. As a library, it presents a single raster abstract data model and single vector abstract data model to the calling application for all supported formats. It also comes with a variety of useful command line utilities for data translation and processing”. Besides QGIS and the command line there are other options for using it, see the list.

In this article, we describe how to use QGIS as well as command line tools to:

  • merge DEM tiles obtained from SRTM (or other) data servers
  • to clip tiles
  • and to translate DEM tiles to STL models

6.1 Installation of QGIS or just GDAL

6.1.1 Installation under Windows 64bit

Take the latest 64 bit version installer from here.

The program is rather large: download is 395MB and installation is 1.6GB.

6.1.2 Installation of QGIS under Ubuntu 16x

To install the huge QGIS, the huge Geographic information systems package, you need to configure a GIS repository

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get update

Now you can select dozens of packages described in Packages in “ubuntugis-stable”. To install QGIS:

sudo apt-get install qgis

6.1.3 Installation under Ubuntu 16x (GDAL only)

We recommend installing a very complete GIS package that will include GDAL, according to these instructions:

Requirements, some python extension and the GIS PPA

  • See above for GIS PPA

The following will install GDAL, including Python bindings

 sudo apt-get install gdal-bin
 sudo apt-get install libgdal-dev
 sudo apt-get install python-gdal
 sudo easy_install gdal

Test if something works. Get a DEM file and see if you can extract information. Examples, using files I extracted from various archives. Each should work and provide about 20-30 lines of information (file content, coordinates, etc.)

gdalinfo n45_e006_1arc_v3.bil
gdalinfo n46_e006_1arc_v3.tif
gdalinfo srtm_38_03.asc 

6.2 Translate files

QGIS:

  • Explore the raster menu

Command line:

gdal_translate can translate many formats, e.g. all common raster and grid formats

gdal_translate -of output input

6.3 Merge images

Since terrain elevation data are available as squares, you may have to merge them in order to extract an area that sits "between tiles". The gdal_merge.py library can do that. Let's also mention that some software also allows working with virtual rasters, i.e. can process several tiles at the same time if they were a real picture. Merging images in QGIS is done with the raster menu:

QGIS: Menu Raster -> Miscellaneous -> Merge.....

  • Select all the files you plan to merge
  • Define the output file
  • Set No data value = 0 for the output (better than -32676, see below)
  • Make sure that "Load into Canvas when finished" is ticked.
Merging *.bil tiles with QGIS

As you can see, there seem to be some "holes" in the result, but that is another problem. If you see such holes, it can mean that you have "no data" values. In our case the number -32767 used for these turn out to be black.

  • To see the nodata value of an input file, right-click on the file in the browser panel and look at properties.

Using the command line tool (btw. QGIS will always show command lines and arguments that you use):

gdal_merge.py -of file_format -o output_file input, input, input, .....

Example:

gdal_merge.py -n -32767 -a_nodata -32767 -of GTiff -o geneva_area.bil n46_e007_1arc_v3.bil n45_e007_1arc_v3.bil n46_e006_1arc_v3.bil n45_e006_1arc_v3.bil n46_e005_1arc_v3.bil n45_e005_1arc_v3.bil

6.4 Dealing with no data values (missing data)

Missing data (called "no data") is already marked as such. They may appear as totally black or white "holes" and you cannot and need not do anything about these if they are very small. Larger areas though need to converted to real values if you plan to 3D print.

In QGIS, load the file into a raster layer if not already done so (see merging above).

  • Menu: Layer -> Add Raster Layer
  • Select a supported file format, e.g. *.asc or *.bil

Now you can decide which values are missing values. In the picture above (merge images), we have single "band" of color: grey. Darker means lower regions, lighter means higher regions. Black is likely "freaky" data, i.e. impossibly high or low. Data points that point deep into the earth, i.e. Min = -32767 are "missing" data and should be ignored:

Min=-32767.000 Max=4267.000 Mean=410.805, StdDev=4753.033
  • Right click on the file name in the layers panel
  • Select properties
  • See if there are "no data value". In our case, we had -32767 which is correct.
no data value STL

Converting missing data to another value

If your missing data represent the bottom of an model that was clipped in the z direction, e.g. you got an island but no sea, you could transform the missing data values to 0. "Reclassifying" no data values is neccessary for using the Demto3D plugin, just described below.


This situation is very easy to spot before you even attempt to produce the STL:

  • The background of your raster is white (while the highest points also look white)
  • In addition, in the DEMto3D popup, you also would see the highest point as 32767

A good solution is therefore to transform the 32767 value (or whatever else) into the lowest value of your model, e.g. 0. To do so use the Reclassify values tool that is part of the SAGA tools (a bit difficult to find):

Processing menu -> Toolbox -> Select SAGA in the panel to the right -> Raster tools -> Reclassify values

Now, in the popup window, scroll down and uncheck replace other values. If you want another value than 0, you can change that. The resulting new raster now should have a black background.

No value data (missing data) being translated to 0

Otherwise, e.g. if you got missing areas within a mountain, you may have to use an algorithm that will interpolate values (I did not investigate how to do this yet, simple substitution will not work, unless you later can smooth them out with Meshlab.).

6.5 Crop/extract tiles

Using the command line tool you could provide coordinates, e.g.

gdal_translate -projwin 5.68197537628 46.6941320621 7.28048142324 45.6929800494 geneva_region.bil geneva_small.bil

Or use the QGIS GUI:

  • Menu Raster -> Extraction -> Clipper
  • Define the name of an output file. File extension will define the output type. By default the "tif" format is used.
  • Select a rectangle and press OK

6.6 Polygonize raster files

In default installations, QGIS and GDAL cannot directly produce usable 3D formats for printing. However, one can produce some polygone formats that one could further translate to STL. We do not suggest using this feature, since we found the resulting files fairly unusable. See the next item.

DEMto3D plugin with missing height base

6.7 Create STL from DEM files with the DEMto3D extension

Installation

To produce directly STL from raster files, install the DEMto3D plugin. From the plugin installation dialog: DEMto3D is the first tool that links GIS (Geographic Information System) and 3D printing. DEMto3D allows export DEM to STL format ready to 3D printing. [..] Author: Francisco Javier Venceslá Simón

  • Menu Plugins
  • In the popup, select Not installed in the left panel
  • Select DEMto3D

Procedure for using DEMto3D

The plugin is available in the Raster menu (once installed):

  • If you already clipped the tile, then select full extent (the little globe), else give coordinates
  • Define spacing (we suggest 0.25mm for larger models)
  • Define width, e.g. 150mm (15cm)
  • Exaggeration factor: 2.0 (or less or more)
  • Model height: Enter the lowest point in meters, i.e. 0 (entering a negative number will have the plugin crash).

Exporting a larger model, e.g. a 40MB geoTiff file took a few minutes. The result STL file was 386MB, i.e. rather large.

The raw result as seen in Meshlab is rather pretty. Of course, it may be pointless to create a model of such a large area with 30m SRTM data. The easy-to-do ways described above should be good enough. Creating model of small areas with more precise data, however, is an option one must consider.

DEMto3D plugin. View of the Montblanc from somwhere over the Jura. Geneva is to the right and Lac d'Annecy top right

Below is a screenshot of the almost ready-to-print 10x10 cm model of the Salève, the Geneva house mountain. It was done with the following parameters:

  • Full extent (I clipped the area before)
  • Size width = 100
  • Lowest point = 100
  • Exageration factor =1

I did not make any changes to the output file. Of course it would be wise to do a preventive Meshrepair. Once also could consider augmenting the exaggeration factor to 1.2 or 1.5 maybe.

DEMto3D plugin. View of the Salève (Netfabb). As you can see model fits on the platform as expected and is well positioned.
DEMto3D plugin. View of the Salève (Meshlab)

Post processing

The STL output is binary. If you started with low resolution data, you have too many triangles which is a not problem per se, but can drastically augment slicing time. Also you cannot email 500MB files. Therefore, read below how to reduced meshes with the free Meshlab program. In addition, I recommend repairing the file with a tool like Netfabb.

So far, I printed two models of the famous Vulcano island using both 2m and 15m resolution *.tif files. Before printing I did reduce a large STL file (made from 2m data) using Meshlab. Before reduction the ascii STL file size was 590MB, the reduced binary STL was 16MB, i.e. more manageable. After reducing I had to fix the STL in Netfabb and it was good for printing. I also printed a model of just the volcano made from 15m data.

DEMto3D plugin. View of Vulcano island (2m data) with a 0.1 reduced mesh (Meshlab)

I do recommend this tool chain, if you work with high resolution tiles and/or if you have data that need some processing (e.g. tiles that need to be assembled and clipped, or no data value files)..

Issues (as of March 2017)

  • If your STL model is deeply hidden at the bottom of a huge tunnel block then you have a no data problem. E.g. if you have a little island and the sea around the island has no data coded with "32767" then the island will sit at the bottom of a 32km high tunnel. See above how to deal with no data values. IMHO this plugin should not compute "no data values", but it does :)
  • The software does not adapt to high resolution screens under Windows (QGIS 2.18.4). Workaround 1: use the TAB to move forward and type blindly. Workaround 2: Adjusting screen resolution and reduce font size to 100% (typically you would use 200% on a high résolution screen and this is the problem).
  • The application may crash under Ubuntu 16/QGIS 2.14.1. Workaround: Use Windows (or maybe install a newer version by hand).

7 Creating STL from geoTIFF elevation maps with gdal and phstl.py

I do not know how well this works, since I focused on other solutions. See the QGIS/DEM23D plugin and the "hills" program above as alternative.

Installation under Ubuntu 16x

Requirements: The GDAL library and its Python bindings. Test if something is there:

ogrinfo

If not, see above (installation of GDAL)

Download the phstl.py script

git clone https://github.com/anoved/phstl.git

Copy the script to some place that is in the PATH,e .g. ~/bin or /usr/local/bin

Transforming a geoTIFF to STL

Get an example file, e.g. from CGIAR-CSI[1] that provide elevation models for the whole world.

You can select a square in an area of interest. However this will create huge files. Most of Sicily sits in a square that is represented by a 72 GB tiff file. Translated this produced a 565 GB (!) STL File, which will be very difficult to handle.

Transform the tif into a non printable STL with phstl.py

Example:

phstl.py srtm_39_05.tif sicily.stl

Since the STL was too huge I did not pursue this.

8 Creating STL from XZY point clouds with Meshlab

(not done yet since I somewhat failed, and then discovered the easy to use AccTrans program, see above)

Some interesting data is available in the form of point clouds, i.e. points defined by their x,y,z coordinates. E.g. 3D scanners produce this kind of output.

I tried creating a model from the free DHM25 Swiss topology office. The download link is at the bottom a provides a zip file that includes a huge dxf files, and two much smaller *.asc and *.xyz files.

Here is the procedure:

  • Import the xyz file

(1) Sample points

Filters -> Sampling -> Poisson-disk Sampling
  • Tick Base Mesh Subsampling
  • Try to go as high as you can, e.g. I just added the number of all vertices.
  • The layer with the transformed data should be active
View -> Open Layer dialog; If needed, highlight poisson-disk samples

(2) Compute normals for the point set. Menu:

Filters-> Point Set -> Compute Normals for point set
  • Tick "Flip normals w.r.t. viewpoints"
  • Change number of neighbors from 10 to 20 or 30
  • Tick "flip normals w.r.t. viewpoint" ??
  • Apply (and wait for a long time if you forgot to sample or if you have a high sample)

(3) Then build the surface

Filters -> Point Set -> Surface Reconstruction : Poisson
  • Set Octree depth = 10

The result of the poisson disk sample looked ok (I could recognize a nice 3D model showing off the Alps, but the final result looked like a bunch of dragons cut into pieces ... The last step somehow went wrong.

9 Mesh reduction with Meshlab

Typical SRTM data sets include a rather high resolution, i.e. a 90 meters grid and models of a smaller area do have a manageable size. But if you plan to print 100 x 100km areas with mountains, I suggest reducing the amount of triangles a bit, unless you got really good hardware.

A good open source mesh manipulation tool is Meshlab, download and install it you don't already own it. If you already got an STL file, you also can use an STL editor, or Autodesk Meshmixer. The later can clean the inside of an object which sometimes is very handy.

Mesh reduction with the Quadric Edge Filter (0.25 is a minimum)

Triangle reduction with Meshlab

Step 1

Menu File -> Import Mesh

Step 2

  • Tick the Wireframe Icon on top

Step 3: Select the (maybe) best triangle reduction filter

Menu Filters -> Remeshing, simplification, and Reconstruction
Quadric Edge Collapse Decimation

Now in the small popup

  • Tick "preserve Normal", maybe also "preserve topology"
  • Enter target number of faces or enter a fraction, e.g. 0.25 as a minimum
  • Apply

Then wait for a while. Verify the result. Sometimes a reduction can alter the overall geometry. The 25% reduced version of the Lake Geneva - Mont Blanc region still took a long time to slice.

MB vertices (points) faces (triangles)
Before 234MB 2'343'502 4'680'670
Reduction to 20% 46.8MB 468'115 936'133
Reduction to 10% 23.4MB 234'195 468'299

I took 20 or 25% versions to slice. Of course one doesn't need that many triangles, but reducing too much may take out some mission critical features, like canyons or mountain tops close to each other. But I don't have any precise idea on that.

After that make sure to pass the mesh through a repair tool. Ideally you should that three times. Before reducing, after reducing and after adjusting the Z-height (I usually multiply by 2).

You also could Meshlab to repair the triangle structure (mesh), but I prefer using Netfabb since it does not require any understanding :)

9.1 Mesh reduction from the command line

Meshlab can be use in command line mode through the meshlabserver program. It comes installed with Meshlab.

Usage:

   meshlabserver arg1 arg2 ...  

where args can be:

-i [filename...]  mesh(s) that has to be loaded
-o [filename...]  mesh(s) where to write the result(s)
-s filename       script to be applied
-d filename       dump on a text file a list of all the filtering fucntion
-l filename       the log of the filters is ouput on a file
-om options       data to save in the output files

In other contexts, it is important to define what features should be saved. None of these are available for STL. It only includes triangles.

List of om options
vc -> vertex colors
vf -> vertex flags
vq -> vertex quality
vn-> vertex normals
vt -> vertex texture coords
fc -> face colors
ff -> face flags
fq -> face quality
fn-> face normals
wc -> wedge colors
wn-> wedge normals
wt -> wedge texture coords

Generic example:

// cleanup with a script and save the same file format
meshlabserver -i input.obj -o output.ply -s meshclean.mlx -om vc fq wn
// simple file conversion
meshlabserver -i input.obj -o output.stl

Mesh reduction and repair script example (the quadratic edge collabse is not ready yet)

meshlabserver -i input.stl -o output.stl -s clustering-decimation-script.mlx

E.g. the following would reduce a large STL terrain file with over 5'000'000 triangles. File clustering-decimation-script.mlx:

<!DOCTYPE FilterScript>
<FilterScript>
 <filter name="Clustering decimation">
  <Param type="RichAbsPerc" value="0.9649" min="0" name="Threshold" max="321.617"/>
  <Param type="RichBool" value="false" name="Selected"/>
 </filter>
 <filter name="Remove Duplicate Faces"/>
 <filter name="Remove Duplicated Vertex"/>
 <filter name="Merge Close Vertices">
  <Param type="RichAbsPerc" value="0.032162" min="0" name="Threshold" max="3.21617"/>
 </filter>
 <filter name="Remove Faces from Non Manifold Edges"/>
 <filter name="Close Holes">
  <Param type="RichInt" value="30" name="MaxHoleSize"/>
  <Param type="RichBool" value="false" name="Selected"/>
  <Param type="RichBool" value="true" name="NewFaceSelected"/>
  <Param type="RichBool" value="true" name="SelfIntersection"/>
 </filter>
</FilterScript>

10 Slicer settings for digital elevation models

Printing Vulcano with my old but reliable Felix 2 printer

Printing 3D terrain models can be very frustrating. I had 2 print aborts before I managed to print my first bigger than 10x10cm model. In order to reduce the amount of these inevitable failed prints, we suggest a few strategies for PLA or another polymer that does not warp. Note that print properties of various PLA are different. Adapt to your filament.

Make sure that the model is error free

  • Use an STL repair tool, e.g. Netfabb or builtin functionality.
  • Verify g-code, e.g. look at the print preview. If you controller or slicer does not allow this, install a tool that includes the same slicer and that can do it, e.g. Repetier host.I did encounter "freeky" parts like areas printed twice. These will make your print head getting stuck and as a result, a likely print abort. You can easily spot these areas in a gcode viewer, because they look very dense.

First layer adherence and warping

Even PLA can and does warp when you print large surfaces.To increase platform adherence and reduce warping, use the following strategies:

  • Print the first (flat) layer slowly (about 30% of default speed, no more than 20mm/second
  • Ventilator off for the first layer.
  • Make the first layer fatter with extra extrusion about 125 to 150%
  • Print it warmly (e.g. 205 degs. for PLA a new printer, and 215 on a old printer)
  • Print the other layers colder (about 195 degs.) You could go lower than that of course, but then you will have the risk that the flow will "dry" up when you print large infills, since bonding is not so easy at 20% infill and high speed. However, if your extruder is not very strong (most older printers do have rather weak ones), print warmer (e.g. 215 degs).
  • You also can consider adding glue or hairspray, but then you may have trouble getting the part off the print bed.

Filling and extrusion width

One of the problems with 3D terrain models is that in some printed areas will exceed their expected height (too much extrusion used for flat areas). The print head then will "dig" into the plastic and if you have a second print head it may want to rip off the whole print from the platform. Therefore you will have to rethink the way to print.

  • 20% filling should be enough.
  • Honeycomb patterns seem to lead to better results but may take more time for printing. However they are more sensitive to retraction getting out of touch,
  • Reduce infill in other ways, e.g. in Slic3r, you could combine 2 layers and "only fill when needed"
  • Verify default extrusion width. It should be set to the width of the nozzle or less, e.g. 0.35mm for a 0.35mm nozzle (For Lego I use 0.38mm).
  • Set extrusion width to 0.9 or less of your landscape has lots of flats and if your PLA includes a lot of paint. It should be lower than the default width value (see above).
  • Do not print more than 2 top or bottom layers if possible. This may be a problem if you got large flat surfaces and you will have to use 3 for each. Ideally, one should have a slicer that allows styles for various heights and sizes (like the Netfabb slicer we got for the infamous fabbster printer). Open source slicers cannot do this (unless I missed any improvement as of March 2017)

Other tips

  • Remove any retraction. On larger prints, I experienced filament drying up. This is probably due to retraction. Each time the filament is pulled back in it has to be pushed out again and after a few hours of printing the hot end may be just warm enough to weaken the plastic a bit. In Slice3R, retraction is set in printer tab (create a new printer profile).
  • Avoid PLA with too much paint inside. That type of PLA not only reduces print quality but also seems to expand more and could possibly include harmful chemicals.

Reduce print time

Even a small object can take a long time to print. E.g. it took 10 hours to print a 13x17x1 cm model of the Geneva basin using 0.2mm layers and settings I designed for printing Lego blocks.

  • Consider using 0.25mm layers. For larger models, the result is OK. Use 0.2mm layers or less for small ones.
  • Use all the filling strategies above.
  • Use a controller that allows speeding up manually a print (e.g. Repetier Host) when you feel that everything goes fine. Some printers, e.g. my Felix Pro also allow this through its control screen.
  • Standard speed can be fairly high, e.g. 60mm/s. If your slicer allows, reduce this for small areas. Consider also reducing the outer perimeter, e.g. I use 50mm/s.
  • Use extra speed for filling, e.g. at least 80mm/s
  • Disable any cooling tower or skirt (unless your object is very small).

Printing upside down

  • I did not try this, but this strategy might allow printing sturdier objects with more infill and more layers on top and bottom. However I suspect that will need a good support structure (raft and or something "around"). Also, you cannot use much extra elevation since this would create difficult to print overhangs.
  • As an example I looked at estimated print time for two version of a file: A horizontal model that would take over 8 hours to print with 25% fill only takes about 7 hours with vertical position and 5% fill. The gain is not very impressive, but you could print 3 models at the same time that way (and pray that one of these doesn't get loose).
  • I probably would add a raft or at least a skirt.

11 Bibliography, links and footnotes

11.1 Citations

  1. Quote: "The CGIAR is a global partnership dedicated to reducing rural poverty, increasing food security, improving human health and nutrition, and ensuring more sustainable management of natural resources. The Consortium for Spatial Information, CSI, is the CGIAR community of geo-spatial scientists that promotes and practices the application of spatial science to achieving these goals most effectively." http://www.cgiar-csi.org/ Feb 2017

11.2 Software

(needs to be completed)

STL extraction from DEM
Viewers
Converters
  • AccuTrans3D. Converter for Windows. For only $20 it can convert between lots of file formats. See a section above for using with Swiss Topo 25m data.
  • QGIS has built-in conververters (raster menu -> translate)
  • 3DEM (Windows Vista) can convert from some DEM formats to others. This program still seems to work under Win8.

11.3 Links

QGIS Tutorials (merging, repairing, etc.)

Height map Tutorials
Point cloud to STL tutorials
Heat map to STL tutorials
KMZ to STL
General tutorials

11.4 3D terrain data

Search and data selection tools
  • Imagico DEM Search. Select a rectangle and a data source. It will provide links to downloadable files.
  • USGS Earth explorer. Select an area on the map, click on data, then select a data source. Registration required.
Selection with STL export
  • Terrain2SL All in one service (explained above). This is the beginner's tool.
Data provided as area files.