# Wed Sep 02 00:10:17 2020 -
# 2020年11月15日更新
# Wed Feb 24 17:21:10 2021 --第二次更新。
#
# 字符编码:UTF-8
# R 版本:R x64 4.0.2 for window 10
# [email protected]
# 个人笔记不负责任
# —— 拎了个梨
rm(list=ls());gc()
.rs.restartR()
# 从mesh3D对象向地图添加多边形
# install.packages("mapdeck")
require(mapdeck)#加载加载包
library(rgl)
require(alphashape3d)
key <- 'xxxxx*****' # 自己到mapbox.com申请的秘钥
key <- mapbox_key
#略微夸大海拔
#
#add_mesh(
# map,
# data = get_map_data(map),
# fill_opacity = NULL,
# elevation = NULL,
# tooltip = NULL,
# auto_highlight = FALSE,
# highlight_colour = "#AAFFFFFF",
# light_settings = list(),
# layer_id = NULL,
# id = NULL,
# palette = "viridis",
# na_colour = "#808080FF",
# legend = FALSE,
# legend_options = NULL,
# legend_format = NULL,
# update_view = TRUE,
# focus_layer = FALSE,
# digits = 6,
# transitions = NULL,
# brush_radius = NULL
# )
# Wed Sep 02 00:19:52 2020 -自带mesh3D对象作图-----------------------------
m <- melbourne_mesh
m$vb[3, ] <- m$vb[3, ] * 50
m %>% str()
mapdeck() %>%
add_mesh(
data = m
)
# Wed Sep 02 00:21:07 2020 -多参数演示-----------------------------
mapdeck(
token = key,
style = mapdeck_style('satellite-streets'),
pitch = 45
) %>%
add_mesh(data = m,
fill_opacity = 0.7 # 透明度
,elevation = 3 # 立体强度
,auto_highlight = T # 鼠标悬停高亮
,highlight_colour = '#FFFFCC90'
,light_settings = T # 灯光参数
)
# Wed Sep 02 01:31:56 2020 --手动构建mesh3D对象----------------------------
require(alphashape3d)
model <- ashape3d(rtorus(1000, 0.5, 2),alpha=0.25)
plot(model, edges=F, vertices=F)
library(rgl)
model2=as.mesh3d(model)
rgl::rgl.close()
shade3d(model2, col='#99CCCC')
# Wed Sep 02 01:27:38 2020 --只支持2D,即使是3D模型----------------------------
mapdeck() %>%
add_mesh(data = model2)
# Sun Nov 15 00:29:17 2020 --end
?melbourne_mesh
m <- translate3d( icosahedron3d(col = "magenta"), 12, 0, 0)
mapdeck() %>%
add_mesh(
data = m
)