library(rgl)
x <- c(1:10, 10:1)
y <- rev(c(rep(c(0, 2), 5), rep(c(1.5, -0.5), 5)))
open3d()
## null
## 1
shade3d( extrude3d(x, y), col = "red" )
rglwidget()
Merge raster and vector data for a 3D scene.
## devtools::install_github("hypertidy/anglr")
f <- system.file("extdata/gebco1.tif", package = "anglr")
## ad hoc scaling as x,y and z are different units
r <- raster::raster(f)/1000
library(sf)
## Linking to GEOS 3.6.2, GDAL 2.2.3, proj.4 4.9.3
nc <- read_sf(system.file("shape/nc.shp", package = "sf"))
library(raster)
## Loading required package: sp
library(anglr)
## Warning: S3 method 'anglr.RasterLayer' was declared in NAMESPACE but not
## found
## objects
## a relief map, triangles grouped by polygon with interpolated raster elevation
p_mesh <- anglr(nc, max_area = 0.008) ## make small triangles ( sq lon-lat degree)
p_mesh$v$z_ <- raster::extract(r, cbind(p_mesh$v$x_, p_mesh$v$y_), method = "bilinear")
## plot the scene
library(rgl)
rgl.clear() ## rerun the cycle from clear to widget in browser contexts
plot(p_mesh)
bg3d("black"); material3d(specular = "black")
rglwidget() ## not needed if you have a local device