-
Notifications
You must be signed in to change notification settings - Fork 3
/
12_transforming_spatial_3D.Rmd
83 lines (37 loc) · 1.84 KB
/
12_transforming_spatial_3D.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Transforming spatial data to 3D forms
## Questions
* What tools exist to convert data to meshes in R?
## Overview
* Teaching: 10 min
## Transforming Spatial Data using modular 3D tools {.exercise}
1. Tell us if you use 3D visualization or meshes in analysis.
This is hard! There's a few scattered tools.
## On CRAN
* `rgl::triangulate` and `decido::earcut` will triangulate polygons with holes but only suitable for plane-filling, because ugly triangles, no control over size and shape.
* `RTriangle::triangulate` (and `sfdct::ct_triangulate`) do high-quality "near-Delaunay" triangulations
* `quadmesh::quadmesh` to create rgl-ready mesh3d from a raster
* `mapview::cubeView` does very compelling interactive raster-cube visualization
* `SymbolixAU/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).
## Quadmesh.
```{r, quadmesh, eval=FALSE}
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.
## Stuff not on CRAN!
* `hypertidy/silicate`, `hypertidy/anglr` - these are evolving together
* this workshop! https://github.com/MilesMcBain/gis_vs_web3D
* `coolbutuseless/threed`
## Triangles or quads in hypertidy (WIP)
This is my work-in-progress approach to meshing any data structure.
```{r, eval=FALSE}
## devtools::install_github("hypertidy/anglr")
## devtools::install_github("hypertidy/silicate")
library(anglr)
triangles <- copy_down(TRI(anySFpolygon), anyRasterDEM)
mesh <- plot3d(triangles)
```