############################## ## 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) # disoc'h = data_osm source("./scripts/enporzhiañ_kartenn.R") ############################## ## Sevel ur gartenn anv <- "Agropyron repens" sub_data <- data %>% filter(anv_latin==anv) data <- merge(municipalities_poly, data_percentages, by.x="ref.INSEE", by.y="ebssa", all.x=TRUE) # Rannañ an dregantadoù dre rummad data$emdroadur_rummad <- cut(data$emdroadur, breaks=c(-0.05, -0.02, -0.01, -0.005, 0, 0.01, 0.02, 0.03, 0.04, 0.12)) data$emdroadur2007_rummad <- cut(data$emdroadur2007_2017, breaks=c(-0.05, -0.02, -0.01, -0.005, 0, 0.01, 0.02, 0.03, 0.04, 0.12)) # Evit gwiriañ: peseurt kumun zo hep emdroadur? data %>% filter(is.na(emdroadur)) # => Plevenon ha Sant-Sinforian (poblañs ebet e 1999, nevez krouet int?) #pdf("./kartenn_dregantad_skolioumamm_publik_prevez_diwan.pdf", width = 25, height = 20) data_simple <- st_simplify(data, preserveTopology = TRUE, dTolerance = 0.001) dept_poly_simple <- st_simplify(dept_poly, preserveTopology = TRUE, dTolerance = 0.001) br <- c(-0.02, -0.01, -0.005, 0, 0.01, 0.02, 0.03, 0.04) ## Diskouez pdf("../kartenn_emdroadur_poblañs.pdf", width=10, height=7) p <- ggplot(data=data_simple, aes(fill=emdroadur, text=paste0(name, "\nEmdroadur: ", round(emdroadur, 3)*100, "%")))+ geom_sf(size=0.1, color="#bfbfbf")+ #scale_fill_manual(values=c("#152a84", binned_scale(aesthetics="fill", scale_name="stepsn", palette=function(x) c("#152a84", "#275da5", "#00ade2", "#c6e7f3", "#f7f4d8", "#fbea68", "#f1b85f", "#e78051", "#e04c45"), breaks=br, limits=c(-0.05, 0.12), guide="colorsteps", labels=paste0(br*100, "%"))+ guides(colour=guide_legend("No data", override.aes=list(colour="grey75")))+ ggtitle(paste0("Emdroadur poblañs kumunioù Breizh etre 1999 ha 2017"))+ theme_void()+ labs(fill="Feur kresk bloaziek ar boblañs etre 1999 ha 2017")+ guides(fill=guide_colorsteps(title.position="top", ticks=TRUE))+ theme(plot.title = element_text(face = "bold", hjust=0.5, size=12), 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() ggplotly(p)