Open mdsumner opened 4 years ago
This implies a "mesh colouring" facility in palr, maybe mesh_pal()
? I.e. https://github.com/AustralianAntarcticDivision/palr/issues/8
Here's a more native approach
library(anglr)
#> This is an early developmental version of anglr (0.4.8.9604),
#> still in an experimental state with changes pending.
x <- sf::st_cast(dplyr::filter(silicate::inlandwaters, Province == "Tasmania"), "POLYGON")[2, ]
#> Warning in st_cast.sf(dplyr::filter(silicate::inlandwaters, Province == :
#> repeating attributes for all sub-geometries for which they may not be constant
topo <- ceramic::cc_elevation(x, zoom = 9)
#> Preparing to download: 56 tiles at zoom = 9 from
#> https://api.mapbox.com/v4/mapbox.terrain-rgb/
xx <- DEL(x, max_area = 2e6)
mesh <- as.mesh3d(copy_down(xx, topo))
#> transforming model vertices to raster coordinate system for copy down
mesh$material$color <- colourvalues::colour_values(colMeans(matrix(mesh$vb[3, mesh$it], 3)))
mesh_plot(mesh, asp = 1)
Created on 2020-04-07 by the reprex package (v0.3.0)
3d version just for fun
library(anglr)
#> This is an early developmental version of anglr (0.4.8.9604),
#> still in an experimental state with changes pending.
x <- sf::st_cast(dplyr::filter(silicate::inlandwaters, Province == "Tasmania"), "POLYGON")[2, ]
#> Warning in st_cast.sf(dplyr::filter(silicate::inlandwaters, Province == :
#> repeating attributes for all sub-geometries for which they may not be constant
topo <- ceramic::cc_elevation(x, zoom = 9)
#> Preparing to download: 56 tiles at zoom = 9 from
#> https://api.mapbox.com/v4/mapbox.terrain-rgb/
xx <- DEL(x, max_area = 1e5)
mesh <- as.mesh3d(copy_down(xx, topo))
#> transforming model vertices to raster coordinate system for copy down
mesh$material$color <- colourvalues::colour_values(colMeans(matrix(mesh$vb[3, mesh$it], 3)))
##mesh_plot(mesh, asp = 1)
plot3d(mesh); rgl::aspect3d(1, 1, 0.02); rgl::clear3d("bboxdeco")