-
Notifications
You must be signed in to change notification settings - Fork 0
/
04B plot geo csv.R
63 lines (53 loc) · 1.79 KB
/
04B plot geo csv.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
pacman::p_load(tidyverse, data.table)
df_all = data.table::fread("input/04 geological/df_all_geo.csv")
## Check Health of Attributes via plot
files = "input/04 geological/features" %>%
list.files(pattern = "csv", full.names = T)
files = files[1:4]
df = files %>%
map(fread) %>%
map(~pivot_longer(., cols = -c(lon,lat),
names_to = "attribute",
values_to = "value") %>%
na.omit() %>%
mutate(attribute = attribute %>% str_remove("_UR|_URI")) %>%
separate(col = attribute,
into = c("title","attribute"),
sep = "_"))
plotter = function(x){
p = x %>%
ggplot(aes(x = lon,
y = lat,
fill = attribute)) +
geom_raster() +
scale_fill_viridis_d(x$title[1]) +
coord_equal() +
labs(title = x$title[1])+
hrbrthemes::theme_ipsum_rc() +
theme(
panel.background = element_rect(fill = "black"),
plot.background = element_rect(fill = "black"),
legend.background = element_rect(fill = "black"),
legend.box = "vertical",
text = element_text(colour = "white"),
axis.text = element_text(colour = "white"),
panel.grid.major.x = element_line(colour = rgb(40, 40, 40, maxColorValue = 255)),
panel.grid.major.y = element_line(colour = rgb(40, 40, 40, maxColorValue = 255))
) +
ggthemr::no_minor_gridlines() +
ggthemr::legend_bottom()+
guides(fill = guide_legend(ncol = 2,
label.theme = element_text(size = 6,
colour = "white")))+
ggthemr::no_legend_title()
ggsave(plot = p,
filename = glue::glue("plot/geological/{x$title[1]}.png"),
width = 5,
height = 7,
units = "cm",
dpi = 320,
scale = 3,
limitsize = F
)
}
df %>% walk(plotter)