From 1f3af6ac12769d2e1e2b441eed96b0d48036c603 Mon Sep 17 00:00:00 2001
From: David Nortes-Martinez <davidnortes@gmail.com>
Date: Fri, 21 Jan 2022 19:10:37 +0100
Subject: [PATCH] new theme 'chatchment'

---
 geau/R/map_so_ii.r | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/geau/R/map_so_ii.r b/geau/R/map_so_ii.r
index b1edc39..69b9aa0 100644
--- a/geau/R/map_so_ii.r
+++ b/geau/R/map_so_ii.r
@@ -31,7 +31,7 @@
 map_so_ii = function(
     dataset,
     dataset_legend = NULL,
-    theme = c("none", "clc", "catnat", "hydro", "population"),
+    theme = c("none", "clc", "catnat", "hydro", "population", "catchment"),
     bar = TRUE,
     path = NULL,
     legend_theme = FALSE,
@@ -196,6 +196,33 @@ map_so_ii = function(
         )
     }
 
+    if ("catchment" %in% theme) {
+        if (missing(detail)) {
+            detail = "0"
+        }
+        detail = match.arg(
+            as.character(detail),
+            choices = c("0", "1", "2")
+        )
+        selection  = geau::so_ii_catchment[["degre"]] == detail
+        geometry = geau::so_ii_catchment[["geometry"]][selection]
+        border = "grey80"
+        color =  scales::alpha("grey80", .5)
+        lwd = 1
+        plot(geometry, border = border, col = color, lwd = lwd, add = TRUE)
+
+        theme_legend = list(
+            title = sprintf("Unit\u00e9 administrative"),
+            legend = "Bassin versant",
+            x = "topright",
+            cex = .8,
+            bg = "white",
+            inset = 0.01,
+            fill = unique(color),
+            border = border
+        )
+    }
+
     if (!missing(dataset)) plot(dataset[["geometry"]], add = TRUE, ...)
 
     plot(geau::so_ii_limit, lwd = 2, add = TRUE)
-- 
GitLab