In R The Volcano dataset has elevation values, but is not a DEM file. How can I convert my DEM files (from earthexplorer.usgs.gov) so that the I can access all the elevation values in a matrix (what is returned by volcano)? I am trying to use r2stl() with the data.
You can use the raster package:
library(raster) dem = raster.open("a_dem') # plot with R library(rasterVis) plot3(dem)
# convert the raster to a matrix (as Volcano) demmat = as.matrix(dem)
Now, you can apply the same procedure as in r2stl/demo/Maungawhau.R
z = demmat x = 1:dim(demmat) y = 1:dim(demmat) library(r2stl) r2stl(x, y, z, filename="dem.stl", show.persp=TRUE)
Result with MeshLab: