README.md

dem2stl

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:

Installation

devtools::install_github("kevinstadler/dem2stl")

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

Usage

wget https://research.cip.cgiar.org/gis/downloads/dataserver/_msk_alt/NLD_msk_alt.zip
unzip NLD_msk_alt.zip
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
rgl::shade3d(m)

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

Full documentation is available at http://kevinstadler.github.io/dem2stl/



kevinstadler/dem2stl documentation built on April 3, 2018, 10:04 a.m.