scatter dem
Opened this issue · 1 comments
mdsumner commented
This is fun, mesh a set of points in xy and plot in rgl or as 2D, options:
- control max area
a
, and othe rproperties ofRTriangle::triangulate
eg.D
for Delaunay criterion - if z is included any Steiner points are automatically interpolated
scatter_dem <- function(x, y = NULL, z = NULL, ...) {
x <- xy.coords(x, y)
x <- cbind(x$x, x$y)
PA <- NA
if (!is.null(z)) {
PA <- matrix(z, nrow = nrow(x))
}
p <- RTriangle::pslg(x, PA = PA)
anglr::as.mesh3d(RTriangle::triangulate(p, ...))
}
library(raster)
library(rgl)
n <- 5000
r <- quadmesh::etopo
x <- cbind(runif(n, -180, 180),
runif(n, -90, 90))
x <- raster::xyFromCell(r, sample(1:ncell(r), n))
clear3d()
mesh_plot(
dem <- scatter_dem(x, z = raster::extract(r, x), a = .5, D = TRUE)
)
plot3d(dem)
auto_3d(z = 30)