dem2stl provides functions to convert digital elevation map (dem) files to .stl (and other) 3d-printable model files. It is different from other packages in that:



dem2stl relies on R's rgl package which requires OpenGL libraries to be installed. On Fedora, these are available through the mesa-libGLU-devel package


nl <- raster::raster("NLD_msk_alt.grd")

# aggregate to 2x2 cells because otherwise West-Friesland is clipped
# (the Noordzeekanal, marked with NA values, is so wide that it would split the
# Netherlands into two separated landmasses, with only the biggest rendered)
nl <- raster::aggregate(nl, 2, fun=max)

# turn DEM into 3d mesh, setting maximum model extent in units (interpreted as mm by most printers), and a thin base plate
m <- dem2stl::dem2mesh(nl, size=100, thicknessratio=0.001)

# inspect model on the screen

# write model to .stl on disk
dem2stl::mesh2stl("nederland.stl", m)

Full documentation is available at

kevinstadler/dem2stl documentation built on June 6, 2019, 1:12 a.m.