Upload depth_interactive_map_alpha.R
Browse files- depth_interactive_map_alpha.R +41 -16
depth_interactive_map_alpha.R
CHANGED
|
@@ -77,12 +77,19 @@ BAR_RAMP <- rev(c(
|
|
| 77 |
"#A8482F", "#8C3320", "#6E2418", "#511811", "#321008", "#3D0F0F"
|
| 78 |
))
|
| 79 |
|
| 80 |
-
# Palettes
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
GIIM_COLORS <- c(
|
| 88 |
"Nulo" = "#f8fafc",
|
|
@@ -94,12 +101,18 @@ GIIM_COLORS <- c(
|
|
| 94 |
"No aplica" = "#94a3b8"
|
| 95 |
)
|
| 96 |
|
| 97 |
-
MIGRANTS_PAL <- c("#
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
# Infrastructure point categories -- grouped from the raw "category" field
|
| 105 |
# (Shelter / restaurant / Government / lodging / Legal/NGO / Food / charity /
|
|
@@ -2681,6 +2694,18 @@ server <- function(input, output, session) {
|
|
| 2681 |
list("interpolate", list("linear"), list("zoom"), from_zoom, 0, to_zoom, 1)
|
| 2682 |
}
|
| 2683 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2684 |
# N7 is lazy-loaded on first selection (113k rows would block renderMaplibre).
|
| 2685 |
grid7_sf <- NULL
|
| 2686 |
grid7_loaded <- reactiveVal(FALSE)
|
|
@@ -2801,7 +2826,7 @@ server <- function(input, output, session) {
|
|
| 2801 |
show_measurements = TRUE
|
| 2802 |
)
|
| 2803 |
|
| 2804 |
-
# --- Satellite imagery (fades in at zoom >
|
| 2805 |
m <- m |>
|
| 2806 |
add_raster_source(
|
| 2807 |
id = "satellite-source",
|
|
@@ -2938,7 +2963,7 @@ server <- function(input, output, session) {
|
|
| 2938 |
id = id,
|
| 2939 |
source = pts,
|
| 2940 |
circle_color = color,
|
| 2941 |
-
circle_radius = radius,
|
| 2942 |
circle_opacity = 0.75,
|
| 2943 |
circle_stroke_color = "rgba(0,0,0,0.4)",
|
| 2944 |
circle_stroke_width = 0.7,
|
|
@@ -2993,7 +3018,7 @@ server <- function(input, output, session) {
|
|
| 2993 |
maplibre_proxy("map") |>
|
| 2994 |
add_circle_layer(
|
| 2995 |
id = id, source = pts,
|
| 2996 |
-
circle_color = color, circle_radius = radius,
|
| 2997 |
circle_opacity = 0.75,
|
| 2998 |
circle_stroke_color = "rgba(0,0,0,0.4)",
|
| 2999 |
circle_stroke_width = 0.7,
|
|
@@ -3013,7 +3038,7 @@ server <- function(input, output, session) {
|
|
| 3013 |
id = "infra-pts",
|
| 3014 |
source = pts,
|
| 3015 |
circle_color = infra_cat_expr(),
|
| 3016 |
-
circle_radius = 3,
|
| 3017 |
circle_opacity = 0.85,
|
| 3018 |
circle_stroke_color = "rgba(0,0,0,0.5)",
|
| 3019 |
circle_stroke_width = 0.8,
|
|
|
|
| 77 |
"#A8482F", "#8C3320", "#6E2418", "#511811", "#321008", "#3D0F0F"
|
| 78 |
))
|
| 79 |
|
| 80 |
+
# Palettes -- ColorBrewer multi-hue sequential ramps. Each layer keeps its
|
| 81 |
+
# semantic hue family but adds a second hue (and steeper chroma) at the dark
|
| 82 |
+
# end so the highest-percentile bin actually pops. All ramps are perceptually
|
| 83 |
+
# monotonic in lightness (light -> dark) so the binning order stays legible
|
| 84 |
+
# to colour-blind users.
|
| 85 |
+
CRIME_STEP_PAL <- c("#f7fcfd", "#e0ecf4", "#bfd3e6", "#9ebcda",
|
| 86 |
+
"#8c96c6", "#8856a7", "#810f7c") # BuPu 7
|
| 87 |
+
DESAP_PAL <- c("#FFFFFF00", "#f1eef6", "#d4b9da", "#c994c7",
|
| 88 |
+
"#df65b0", "#dd1c77", "#980043") # PuRd 6 + transparent
|
| 89 |
+
PAM_PAL <- c("#ffffd9", "#edf8b1", "#c7e9b4", "#7fcdbb",
|
| 90 |
+
"#41b6c4", "#1d91c0", "#225ea8") # YlGnBu 7
|
| 91 |
+
ENVIPE_PAL <- c("#fef0d9", "#fdcc8a", "#fc8d59", "#e34a33",
|
| 92 |
+
"#b30000", "#7f0000") # OrRd 6
|
| 93 |
|
| 94 |
GIIM_COLORS <- c(
|
| 95 |
"Nulo" = "#f8fafc",
|
|
|
|
| 101 |
"No aplica" = "#94a3b8"
|
| 102 |
)
|
| 103 |
|
| 104 |
+
MIGRANTS_PAL <- c("#ffffb2", "#fecc5c", "#fd8d3c",
|
| 105 |
+
"#f03b20", "#bd0026", "#800026") # YlOrRd 6
|
| 106 |
+
GRAVES_PAL <- c("#fee5d9", "#fcae91", "#fb6a4a",
|
| 107 |
+
"#de2d26", "#a50f15", "#67000d") # Reds 6
|
| 108 |
+
INFRA_PAL <- c("#ffffe5", "#f7fcb9", "#d9f0a3",
|
| 109 |
+
"#addd8e", "#78c679", "#238443") # YlGn 6
|
| 110 |
+
OCVED_PAL <- c("#feedde", "#fdbe85", "#fd8d3c",
|
| 111 |
+
"#e6550d", "#a63603", "#7f2704") # Oranges 6
|
| 112 |
+
GED_PAL <- c("#f1eef6", "#d0d1e6", "#a6bddb",
|
| 113 |
+
"#67a9cf", "#2b8cbe", "#045a8d") # PuBu 6
|
| 114 |
+
FOSAS_PAL <- c("#ffffd4", "#fee391", "#fec44f",
|
| 115 |
+
"#fe9929", "#d95f0e", "#993404") # YlOrBr 6
|
| 116 |
|
| 117 |
# Infrastructure point categories -- grouped from the raw "category" field
|
| 118 |
# (Shelter / restaurant / Government / lodging / Legal/NGO / Food / charity /
|
|
|
|
| 2694 |
list("interpolate", list("linear"), list("zoom"), from_zoom, 0, to_zoom, 1)
|
| 2695 |
}
|
| 2696 |
|
| 2697 |
+
# Maplibre interpolate expression for circle_radius. At national zoom the
|
| 2698 |
+
# radius is ~0.7x base (dots stay small so the map isn't drowned in points);
|
| 2699 |
+
# at street zoom it grows to ~3.2x base so individual incidents are legible.
|
| 2700 |
+
zoom_radius_expr <- function(base = 2) {
|
| 2701 |
+
list("interpolate", list("linear"), list("zoom"),
|
| 2702 |
+
4, max(1, base * 0.7),
|
| 2703 |
+
7, base,
|
| 2704 |
+
10, base * 1.6,
|
| 2705 |
+
13, base * 2.4,
|
| 2706 |
+
16, base * 3.2)
|
| 2707 |
+
}
|
| 2708 |
+
|
| 2709 |
# N7 is lazy-loaded on first selection (113k rows would block renderMaplibre).
|
| 2710 |
grid7_sf <- NULL
|
| 2711 |
grid7_loaded <- reactiveVal(FALSE)
|
|
|
|
| 2826 |
show_measurements = TRUE
|
| 2827 |
)
|
| 2828 |
|
| 2829 |
+
# --- Satellite imagery (fades in at zoom > 13) ----------------------------
|
| 2830 |
m <- m |>
|
| 2831 |
add_raster_source(
|
| 2832 |
id = "satellite-source",
|
|
|
|
| 2963 |
id = id,
|
| 2964 |
source = pts,
|
| 2965 |
circle_color = color,
|
| 2966 |
+
circle_radius = zoom_radius_expr(radius),
|
| 2967 |
circle_opacity = 0.75,
|
| 2968 |
circle_stroke_color = "rgba(0,0,0,0.4)",
|
| 2969 |
circle_stroke_width = 0.7,
|
|
|
|
| 3018 |
maplibre_proxy("map") |>
|
| 3019 |
add_circle_layer(
|
| 3020 |
id = id, source = pts,
|
| 3021 |
+
circle_color = color, circle_radius = zoom_radius_expr(radius),
|
| 3022 |
circle_opacity = 0.75,
|
| 3023 |
circle_stroke_color = "rgba(0,0,0,0.4)",
|
| 3024 |
circle_stroke_width = 0.7,
|
|
|
|
| 3038 |
id = "infra-pts",
|
| 3039 |
source = pts,
|
| 3040 |
circle_color = infra_cat_expr(),
|
| 3041 |
+
circle_radius = zoom_radius_expr(3),
|
| 3042 |
circle_opacity = 0.85,
|
| 3043 |
circle_stroke_color = "rgba(0,0,0,0.5)",
|
| 3044 |
circle_stroke_width = 0.8,
|