R语言,rayshader包,render_scalebar函数,添加比例尺

比例尺(跟栏杆似的)
多条栏杆
分为三段和多条栏杆
长短和不同色彩栏杆
# Thu Oct 15 17:09:21 2020 -

# 字符编码:UTF-8
# R 版本:R x64 4.0.2 for window 10
# cgh163email@163.com
# 个人笔记不负责任
# —— 拎了个梨🍐
.rs.restartR()
rm(list=ls());gc()
# render_scalebar函数,比例尺
require(rayshader)
# 在地图上放置指南针以指定北向。
#Add a scale bar to the montereybay dataset, here representing about 80km
## Not run:
montereybay %>%
  sphere_shade() %>%
  plot_3d(montereybay,theta=45, water=TRUE)
render_scalebar(limits=c(0, 80), label_unit = "km")
render_snapshot()
 dev.copy(png,'比例尺(跟栏杆似的).jpg');dev.off()

#支持高质量渲染:

render_highquality(lightdirection=250, lightaltitude=40, scale_text_size=24,clamp_value=10)
render_scalebar(clear_scalebar = TRUE)

#我们可以通过将基本方向指定为“ position”来更改位置,并通过设置“ color_first”和“ color_second”来设置#color

render_scalebar(limits=c(0,80), label_unit = "km", position = "N",
                color_first = "darkgreen", color_second = "lightgreen")
render_snapshot()
render_scalebar(clear_scalebar = TRUE)

dev.copy(png,'多条栏杆.jpg');dev.off()


#通过设置“ text_switch_side = TRUE”来切换方向
render_scalebar(limits=c(0,80), label_unit = "km", position = "N", text_switch_side = TRUE,
                color_first = "darkgreen", color_second = "lightgreen")
render_snapshot()
render_scalebar(clear_scalebar = TRUE)

#我们可以通过在“限制”中指定其他距离来添加其他休息时间
render_scalebar(limits=c(0,40,80), label_unit = "km")
render_snapshot()
render_scalebar(clear_scalebar = TRUE)
dev.copy(png,'分为三段和多条栏杆.jpg');dev.off()

#我们还可以通过设置y参数来手动指定高度:
render_scalebar(limits=c(0,40,80), y=-70, label_unit = "km")
render_snapshot()
render_scalebar(clear_scalebar = TRUE)

#在这里,我们通过在侧面指定起点和终点来更改总大小,#并设置彩色的“ segments”的数量:
render_scalebar(limits=c(0,20, 40), segments = 4, scale_length = c(0.5,1), label_unit = "km")
render_scalebar(limits=c(0,20, 40), segments = 4, position = "N", text_switch_side = TRUE,
                scale_length = c(0.25,0.75), label_unit = "km")
render_snapshot()
render_scalebar(clear_scalebar = TRUE)
dev.copy(png,'长短和不同色彩栏杆.jpg');dev.off()

#用“ radius”更改比例尺的半径。 在这里,自动定位不适用于#the标签,因此我们提供了带有`text_y_offset`和`text_x_offset`的附加偏移量以对其进行修复。
render_scalebar(limits=c(0,20, 40), segments = 4, scale_length = c(0.5,1),
                label_unit = "km", radius=10,text_y_offset=-20,text_x_offset=20)
render_snapshot(clear=TRUE)
dev.copy(png,'更粗的栏杆.jpg');dev.off()

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容