/
11_3D.R
88 lines (69 loc) · 2.26 KB
/
11_3D.R
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# https://www.worldpop.org
library(rayshader)
library(raster)
swe_pop <- raster("swe_pd_2020_1km.tif")
swe <- raster_to_matrix(swe_pop)
swe %>%
sphere_shade(texture = rayshader::create_texture("#FCD02D", "#FCD02D", "#FCD02D", "#FCD02D", "#10588E")) %>%
plot_3d(swe,
zscale = 25,
fov = 0, theta = 0,
zoom = 0.85,
phi = 45,
soliddepth = -20, solidcolor = "grey66", shadow = TRUE, shadowdepth = -50,
shadowcolor = "white", background = "black",
windowsize = c(1200, 1000)
)
render_snapshot("12_population.png",
software_render = TRUE, width = 3000, height = 1500, cache_filename = "tmp",
vignette = FALSE
)
nor_pop <- raster("nor_pd_2020_1km.tif")
nor <- raster_to_matrix(nor_pop)
nor %>%
sphere_shade(texture = rayshader::create_texture("#00205B", "#00205B", "#00205B", "#00205B", "#BA0C2F")) %>%
plot_3d(nor,
zscale = 5,
fov = 0, theta = 0,
zoom = 0.75,
phi = 45,
soliddepth = -20, solidcolor = "grey66", shadow = TRUE, shadowdepth = -50,
shadowcolor = "white", background = "black",
windowsize = c(3000, 1500)
)
render_snapshot("12_supplement_nor.png", software_render = FALSE, vignette = FALSE)
fin_pop <- raster("fin_pd_2020_1km.tif")
fin <- raster_to_matrix(fin_pop)
fin %>%
sphere_shade(texture = rayshader::create_texture("#002F6C", "#002F6C", "#002F6C", "#002F6C", "white")) %>%
plot_3d(fin,
zscale = 5,
fov = 0, theta = 0,
zoom = 0.95,
phi = 45,
soliddepth = -20, solidcolor = "grey66", shadow = TRUE, shadowdepth = -50,
shadowcolor = "white", background = "black",
windowsize = c(3000, 1500)
)
render_snapshot("12_supplement_fin.png", software_render = FALSE, vignette = FALSE)
ice_pop <- raster("isl_pc_2020_1km.tif")
ice <- raster_to_matrix(ice_pop)
Reykjavik <- c(-21.9426, 64.1466)
ice %>%
sphere_shade(texture = rayshader::create_texture("#02529C", "#02529C", "#02529C", "#02529C", "white")) %>%
plot_3d(ice,
zscale = 1.5,
fov = 0, theta = 0,
zoom = 1.0,
phi = 45,
soliddepth = -40, solidcolor = "grey66", shadow = TRUE, shadowdepth = -70,
windowsize = c(1200, 1000)
)
render_snapshot("12_population.png",
title_text = "",
title_offset = c(60, 50),
title_color = "black",
title_size = 40,
title_font = "Oxygen",
vignette = FALSE
)