8 Transforming spatial data to 3D forms
8.1 Questions
- What tools exist to convert data to meshes in R?
8.2 Overview
- Teaching: 10 min
8.3 Transforming Spatial Data using modular 3D tools
- Tell us if you use 3D visualization or meshes in analysis.
This is hard! There’s a few scattered tools.
8.4 On CRAN
rgl::triangulate
anddecido::earcut
will triangulate polygons with holes but only suitable for plane-filling, because ugly triangles, no control over size and shape.RTriangle::triangulate
(andsfdct::ct_triangulate
) do high-quality “near-Delaunay” triangulationsquadmesh::quadmesh
to create rgl-ready mesh3d from a rastermapview::cubeView
does very compelling interactive raster-cube visualizationSymbolixAU/mapdeck
tylermorganwall/rayshader
Side note: there are many triangulation algorithms and many packages in R, but we need constrained triangulation to preserve all input edges - only a handful can do that, and RTriangle is the king (with a problematic license).
8.5 Quadmesh.
library(quadmesh)
quadmesh(anyRasterDEM, texture = anyRasterRGB)
rgl::shade3d()
## play with aspect3d, light3d, ...
Triangulations, sfdct
is no good because it’s very inefficient. sf
is simply not suitable for mesh (a.k.a. indexed) forms of data.
8.6 Stuff not on CRAN!
hypertidy/silicate
,hypertidy/anglr
- these are evolving togetherthis workshop! https://github.com/MilesMcBain/gis_vs_web3D
coolbutuseless/threed
8.7 Triangles or quads in hypertidy (WIP)
This is my work-in-progress approach to meshing any data structure.
## devtools::install_github("hypertidy/anglr")
## devtools::install_github("hypertidy/silicate")
library(anglr)
triangles <- copy_down(TRI(anySFpolygon), anyRasterDEM)
mesh <- plot3d(triangles)