From fd0b2c63c8d6123601d86d1301afc16c9f8c5f84 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Grelot?= <frederic.grelot@irstea.fr>
Date: Tue, 22 Nov 2022 08:12:12 +0100
Subject: [PATCH] =?UTF-8?q?D=C3=A9placement=20de=20topage.R=20dans=20le=20?=
 =?UTF-8?q?bon=20d=C3=A9p=C3=B4t?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 script/topage.R | 90 -------------------------------------------------
 1 file changed, 90 deletions(-)
 delete mode 100644 script/topage.R

diff --git a/script/topage.R b/script/topage.R
deleted file mode 100644
index 72984dd..0000000
--- a/script/topage.R
+++ /dev/null
@@ -1,90 +0,0 @@
-# Libraries
-
-library(geau)
-library(sf)
-
-# Waterbody
-
-## Data
-
-waterbody = sf::st_read(geau::current_version("data-common/data/topage/plan_eau", "shp"))
-waterbody = sf::st_transform(waterbody, crs = st_crs(geau::so_ii_limit))
-waterbody = waterbody[
-    lengths(sf::st_intersects(waterbody, geau::so_ii_limit)) > 0,
-    c("CdOH", "TopoOH")
-]
-names(waterbody) = c("id", "name", "geometry")
-waterbody = sf::st_intersection(waterbody, geau::so_ii_limit)
-
-## Save
-
-sf::st_write(waterbody, "data-common/so-ii/topage/2021-09/plan_eau.shp", append = FALSE)
-
-# Catchment
-
-## Functions
-
-prepare_catchment = function (sf_data, name, degre) {
-    selection = sf_data[[sprintf("detail_%s", degre)]] == name
-    sf::st_sf(
-        "id" = NA,
-        "catchment_name" = name,
-        "degre" = degre,
-        "geometry" = sf::st_union(sf_data[selection, ])
-    )
-}
-
-## Data
-
-input_dir = geau::current_version("data-common/data/topage/bassin_versant")
-catchment = sf::st_read(file.path(input_dir, "06_Rhone-Mediterranee_BassinVersantTopographique.shp"))
-classification = read.csv2(geau::current_version("data-common/so-ii/topage", "bassin"))
-
-## Treatments
-
-### CRS
-
-if (!sf::st_crs(catchment) == sf::st_crs(geau::so_ii_limit)) {
-    catchment = sf::st_transform(catchment, crs = sf::st_crs(geau::so_ii_limit))
-}
-
-### Selection & renaming
-
-selection_col = c("CdOH", "geometry")
-selection_row = classification[["id"]]
-
-catchment = catchment[catchment[["CdOH"]] %in% unlist(unname(selection_row)), selection_col]
-names(catchment) = c("id", "geometry")
-catchment = merge(catchment, classification)
-
-### Making catchments
-
-detail_1 = do.call(rbind,
-    lapply(
-        unique(catchment[[sprintf("detail_%s", 1)]]),
-        prepare_catchment,
-        sf_data = catchment,
-        degre = 1
-    )
-)
-detail_2 = do.call(rbind,
-    lapply(
-        unique(catchment[[sprintf("detail_%s", 2)]]),
-        prepare_catchment,
-        sf_data = catchment,
-        degre = 2
-    )
-)
-detail_3 = catchment[c("id", "catchment_name")]
-detail_3[["degre"]] = "3"
-detail_3 = detail_3[names(detail_1)]
-
-catchment = do.call(rbind, list(detail_1, detail_2, detail_3))
-
-### Save
-
-sf::st_write(
-    catchment,
-    "data-common/so-ii/topage/2021-09/bassin_versant.shp",
-    append = FALSE
-)
-- 
GitLab