#remotes::install_cran(c("anglr", "silicate"))
library(silicate)
library(anglr)
library(rgl)
## volcano is heightmap, doesn't exist in geo-space in R so we map it do the extent of
## these spatial polygons
poly <- silicate::minimal_mesh
# xmin : 0
# xmax : 1.23
# ymin : 0
# ymax : 1
## arbitrarily drape polygons over raster
hmap <- raster::setExtent(raster::raster(volcano), raster::extent(0, 1.23, 0, 1))
## use DEL0 so we can control triangle area (not possible with decido, without
## post-hoc subdivision)
triangles <- copy_down(DEL0(poly, max_area = 0.001), hmap)
mesh1 <- as.mesh3d(triangles)
open3d();plot3d(mesh1)
aspect3d(1, 1, 0.5)
# that was just polygons + raster, so now make an image from the raster and
# texture it on (this could be a photograph, a map, just needs to be a 3-layer RGB raster)
im <- palr::image_raster(hmap, col = viridis::viridis(32))
mesh2 <- as.mesh3d(triangles, image_texture = im)
open3d(); plot3d(mesh2)
aspect3d(1, 1, 0.2)
Forked from mdsumner/anglr+silicate_elevate_polygons_image.md
Created
May 20, 2020 09:59
-
-
Save coolbutuseless/0d71d81cf0d788ec48b110298e8c6581 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment