anglr
anglr copied to clipboard
interpolating from contours
This is not good enough:
dp <- "../vr_vs_sp/alexander_clark_park/QSC_Extracted_Data_20171212_140035727000-20064"
f <- file.path(dp, "Contours_1_metre.shp")
library(sf)
clines <- read_sf(f)
x <- clines
x$FEATUREREL <- x$REVISED <- x$ATTRIBUTER <- NULL
x <- st_cast(rmapshaper::ms_simplify(x,keep = .5))
pryr::object_size(x)
plot(x[, 1])
zclines <- st_set_geometry(x,
st_sfc(lapply(seq_len(nrow(x)),
function(ifeature) st_multilinestring(lapply(st_geometry(x)[[ifeature]],
function(jring) cbind(jring,
x$ELEVATION[ifeature])))),
crs = st_crs(x))
)
## try something else
p <- silicate::PATH(zclines)
edges <- sc_edge(p)
ee <- cbind(match(edges$.vertex0, p$vertex$vertex_),
match(edges$.vertex1, p$vertex$vertex_))
library(RTriangle)
psg <- pslg(P = as.matrix(p$vertex[, c("x_", "y_")]),
S = ee)
tri_lines <- RTriangle::triangulate(psg)
tri <- RTriangle::triangulate(pslg(psg$P))
pp <- pslg(tri$P, S = rbind(tri_lines$S, tri$S),
PA = cbind(p$vertex$z_))
pt <- RTriangle::triangulate(pp)
dim(pt$P)
a <- anglr:::th3d()
a$vb <- t(cbind(pt$P, pt$PA, 1))
a$it <- t(pt$T)
#a <- rgl::subdivision3d(a)
rgl.clear()
shade3d(a, col = "white")
rgl::aspect3d(1, 1, .02)
rgl::rglwidget()