sevel-atlas/scripts/main.R

62 lines
1.9 KiB
R
Raw Normal View History

2022-11-04 05:30:54 +00:00
##############################
## Config
# Cheñch teuliad
source_path <- rstudioapi::getActiveDocumentContext()$path
setwd(dirname(dirname(source_path)))
##############################
## Enporzhiañ ha treiñ ar roadennoù
# (ar roadennoù kriz = ur restr evit ul lec'h)
# disoc'h = data
source("./scripts/enporzhiañ.R")
##############################
## Enporzhiañ peadra d'ober ur gartenn
# (harzoù hag all)
2022-11-04 06:05:29 +00:00
# disoc'h = kumuniou, kumuniou_poly, kumuniou_poly_simple, dept, dept_poly, dept_poly_simple
2022-11-04 05:30:54 +00:00
source("./scripts/enporzhiañ_kartenn.R")
##############################
## Sevel ur gartenn
library(ggplot2)
library(ggrepel)
for(s in unique(data$strollad)) {
#grDevices::cairo_pdf(paste0("./res/strollad_", s, ".pdf"), width=10, height=7, onefile=TRUE)
#pdf(paste0("./res/strollad_", s, ".pdf"), width=10, height=7, onefile=TRUE)
data_strollad <- data %>%
filter(strollad==s)
for(anv in unique(data_strollad$anv_latin)) {
grDevices::cairo_pdf(paste0("./res/",s, "_", anv, " (kumuniou).pdf"), width=10, height=7, onefile=TRUE)
sub_data <- data %>%
filter(anv_latin==anv) %>%
tidyr::unite(., label, anv_bzg_1, anv_bzg_2, anv_bzg_3, na.rm=TRUE, sep="\n")
p <- ggplot(data=kumuniou_poly_simple)+
geom_sf(size=0.1, color="#bfbfbf")+
ggtitle(substitute(''~italic(x), list(x=anv)))+
theme_void()+
# Pikoù
geom_point(data=sub_data, aes(x=hed, y=led))+
# Anvioù
geom_label_repel(data=sub_data, color=alpha("black", 1), hjust=0,
nudge_x=0.1, size=4,
aes(x=hed, y=led, label=label))+
# Neuz
theme(plot.title = element_text(face = "bold", hjust=0.5, size=20),
legend.position="bottom",
legend.title=element_text(size=10),
legend.key.width=unit(0.5, "inches"),
legend.key.height=unit(0.1, "inches"))
print(p)
dev.off()
}
#dev.off()
}
2022-11-04 05:30:54 +00:00