diff --git a/dev/package.development.R b/dev/package.development.R index 07d65fa1cc78cbe4139a19936da766ccdbd9292e..ceee3bdf02f39b256a1a22953e4e318478b9eef3 100644 --- a/dev/package.development.R +++ b/dev/package.development.R @@ -8,11 +8,11 @@ devtools::build_vignettes(package) # devtools::run_examples(package) ### Checks -# system("mv ~/.Rprofile ~/.Rprofile-temp");devtools::check(package);system("mv ~/.Rprofile-temp ~/.Rprofile") +# system("mv ~/.Rprofile ~/.Rprofile-temp");devtools::check(package);system("mv ~/.Rprofile-temp ~/.Rprofile") # nolint ### Build devtools::build(package, path = "library", vignettes = TRUE) ### install -> sudo # devtools::install_local(package) -sudo su - -c "R -e \"devtools::install_gitlab('geau-inondation/geau-utility', subdir = 'geau', host = 'gitlab.irstea.fr', upgrade = 'never', auth_token = 'rCEfcrjoms9UNykCuM5c')\"" \ No newline at end of file +sudo su - -c "R -e \"devtools::install_gitlab('geau-inondation/geau-utility', subdir = 'geau', host = 'gitlab.irstea.fr', upgrade = 'never', auth_token = 'rCEfcrjoms9UNykCuM5c')\"" # nolint \ No newline at end of file diff --git a/map/map_so_ii.R b/map/map_so_ii.R deleted file mode 100644 index 2283457c9f1b9ec607f97f6eb6fa28f3d2bff000..0000000000000000000000000000000000000000 --- a/map/map_so_ii.R +++ /dev/null @@ -1,76 +0,0 @@ -# Data to be included in library -so_ii = readRDS("data-common/data/so-ii/so-ii_perim.rds") -so_ii_clc = readRDS("data-common/data/so-ii/so-ii_clc.rds") - -# Map - -map_so_ii = function(dataset, dataset_legend = NULL, theme = "clc", bar = TRUE, path = NULL, ...) { - - if (!is.null(path)) { - switch( - EXPR = tolower(tools::file_ext(path)), - "pdf" = pdf(path), - "png" = png(path), - error(sprintf("%s not recognized", tolower(tools::file_ext(path)))) - ) - } - - ## Init map - par(mai = c(.65, .60, .50, .15)) - plot(so_ii, axes = TRUE) - plot(so_ii, lwd = 2, add = TRUE) - - if ("clc" %in% theme) { - color_clc = scales::alpha(c("red3", "darkolivegreen3", "darkgreen", "#4C90B4", "lightblue"), .2) - color = as.character(cut( - as.integer(substr(so_ii_clc[["code_18"]], 1, 1)), - breaks = 5, - labels = color_clc)) - plot(so_ii_clc$geometry, border = NA, col = color, add = TRUE) - } - - plot(dataset$geometry, add = TRUE, ...) - - if (bar == TRUE) { - terra::sbar(10, c(3.55, 43.47), type = "bar", below = "km", label = c(0, 5, 10), cex = .8) - } - - if (!is.null(dataset_legend)) { - dataset_legend = c( - x = "bottomright", - cex = .8, - bg = "white", - inset = 0.01, - dataset_legend) - do.call(legend, dataset_legend) - } - - if (!is.null(path)) invisible(dev.off()) -} - - -# Data to be plot -dataset = rio::import("data-common/table/so-ii/rex-2020.ods", which = 1) -dataset = dataset[!is.na(dataset$latitude), ] -dataset = sf::st_as_sf(dataset, coords = c("longitude", "latitude"), crs = "WGS84") - -# Color -bg = rep(NA, nrow(dataset)) -bg[dataset[["viticulture"]]] = "deeppink4" -bg[dataset[["habitant"]]] = "cornflowerblue" -col = "black" -cex = 1.4 -pch = 21 - -# Legend -dataset_legend = list( - title = "Enquêtes du REX 19 septembre 2020", - legend = c("Agriculteurs", "Habitants membre ROI"), - pch = 21, - pt.bg = c("deeppink4", "cornflowerblue"), - pt.cex = 1.4 -) - -map_so_ii(dataset, dataset_legend, path = "toto.pdf", bg = bg, cex = cex, col = col, pch = pch) -map_so_ii(dataset, dataset_legend, path = "toto.png", bg = bg, cex = cex, col = col, pch = pch) -map_so_ii(dataset, dataset_legend, path = "toto.pdf", bg = bg, pch = 22) \ No newline at end of file diff --git a/map/map_so_ii.rmd b/map/map_so_ii.rmd new file mode 100644 index 0000000000000000000000000000000000000000..123de2dcd16c3b48784c2458102de7feda2df4a5 --- /dev/null +++ b/map/map_so_ii.rmd @@ -0,0 +1,25 @@ +```{r library} +library(sf) +library(geau) +``` + +```{r update-map} +path = "data-common/figure/so-ii/map/theme/so-ii-%s.pdf" + +map_so_ii(theme = "osm", theme_legend = TRUE, path = sprintf(path, "osm")) +map_so_ii(theme = "collectivity", path = sprintf(path, "collectivity")) +map_so_ii(theme = "collectivity", detail = "syndicate", path = sprintf(path, "syndicate")) +map_so_ii(theme = "collectivity", detail = "epci", path = sprintf(path, "epci")) +map_so_ii(theme = "clc", theme_legend = TRUE, path = sprintf(path, "clc")) +map_so_ii(theme = "population", theme_legend = TRUE, path = sprintf(path, "population")) +map_so_ii(theme = "catnat", theme_legend = TRUE, path = sprintf(path, "catnat")) +map_so_ii(theme = "catchment", theme_legend = TRUE, path = sprintf(path, "catchment")) +map_so_ii(so_ii_hydro[as.character(so_ii_hydro$degre) <= 2, ], col = scales::colour_ramp(c("white", "blue"))(.5), border = NA, theme = "catchment", detail = 2, theme_legend = TRUE, path = sprintf(path, "catchment_sub")) +map_so_ii(theme = "onrn", detail = "freq_sin", theme_legend = TRUE, path = sprintf(path, "freq_sin")) +map_so_ii(theme = "onrn", detail = "cost", theme_legend = TRUE, path = sprintf(path, "cost")) +map_so_ii(theme = "onrn", detail = "cost_hab", theme_legend = TRUE, path = sprintf(path, "cost_hab")) +map_so_ii(theme = "onrn", detail = "cost_mean", theme_legend = TRUE, path = sprintf(path, "cost_mean")) +map_so_ii(theme = "onrn", detail = "ratio", theme_legend = TRUE, path = sprintf(path, "ratio")) +map_so_ii(theme = "onrn", detail = "balance", theme_legend = TRUE, path = sprintf(path, "balance")) +map_so_ii(theme = "onrn", detail = "ppri_year", theme_legend = TRUE, path = sprintf(path, "ppri_year")) +```