-
Notifications
You must be signed in to change notification settings - Fork 1
/
03_generate_stats.R
190 lines (150 loc) · 8.4 KB
/
03_generate_stats.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
library(tidyverse)
library(sf)
#### Load data ----
existing_dams <- readRDS("outputs/rds/existing_dams_scenarios.rds") %>%
st_drop_geometry()
projected_dams <- readRDS("outputs/rds/projected_dams_scenarios.rds") %>%
st_drop_geometry()
all_dams <- readRDS("outputs/rds/all_dams_scenarios.rds") %>%
st_drop_geometry()
#### 1. GRanD & Change in Scarcity (Pessimistic 2050) ----
## Number of dams
# ...exposed to medium to very high risk over time
tibble(
time = c(2020, 2030,2050),
optimistic = c(tally(filter(existing_dams, RC1 > 2.6))[[1]], tally(filter(existing_dams, RC1_O30 > 2.6))[[1]], tally(filter(existing_dams, RC1_O50 > 2.6))[[1]]),
current = c(tally(filter(existing_dams, RC1 > 2.6))[[1]], tally(filter(existing_dams, RC1_C30 > 2.6))[[1]], tally(filter(existing_dams, RC1_C50 > 2.6))[[1]]),
pessimistic = c(tally(filter(existing_dams, RC1 > 2.6))[[1]], tally(filter(existing_dams, RC1_P30 > 2.6))[[1]], tally(filter(existing_dams, RC1_P50 > 2.6))[[1]])
) %>%
mutate_at(vars(optimistic, current, pessimistic), .funs = list(perc = ~ ./tally(existing_dams)[[1]]))
# ...likely to face increase in risk
tally(filter(existing_dams, RC1_P50rc > 0.2))/tally(existing_dams) # 806/2488 (32%)
#### 2. GRanD & Change in Flooding (Pessimistic 2050) ----
## Number of dams
# ...exposed to medium to very high risk over time
tibble(
time = c(2020, 2030,2050),
optimistic = c(tally(filter(existing_dams, RC2 > 2.6))[[1]], tally(filter(existing_dams, RC2_O30 > 2.6))[[1]], tally(filter(existing_dams, RC2_O50 > 2.6))[[1]]),
current = c(tally(filter(existing_dams, RC2 > 2.6))[[1]], tally(filter(existing_dams, RC2_C30 > 2.6))[[1]], tally(filter(existing_dams, RC2_C50 > 2.6))[[1]]),
pessimistic = c(tally(filter(existing_dams, RC2 > 2.6))[[1]], tally(filter(existing_dams, RC2_P30 > 2.6))[[1]], tally(filter(existing_dams, RC2_P50 > 2.6))[[1]])
) %>%
mutate_at(vars(optimistic, current, pessimistic), .funs = list(perc = ~ ./tally(existing_dams)[[1]]))
# ...likely to face decrease in risk
tally(filter(existing_dams, RC2_P50rc < -0.2))/tally(existing_dams) # 1056/2488 (42%)
# ...likely to face increase in risk
tally(filter(existing_dams, RC2_P50rc > 0.2))/tally(existing_dams) # 906/2488 (36%)
#### 3. FHReD & Change in Scarcity (Pessimistic 2050) ----
## Number of dams
# ...exposed to medium to very high risk over time
tibble(
time = c(2020, 2030,2050),
optimistic = c(tally(filter(projected_dams, RC1 > 2.6))[[1]], tally(filter(projected_dams, RC1_O30 > 2.6))[[1]], tally(filter(projected_dams, RC1_O50 > 2.6))[[1]]),
current = c(tally(filter(projected_dams, RC1 > 2.6))[[1]], tally(filter(projected_dams, RC1_C30 > 2.6))[[1]], tally(filter(projected_dams, RC1_C50 > 2.6))[[1]]),
pessimistic = c(tally(filter(projected_dams, RC1 > 2.6))[[1]], tally(filter(projected_dams, RC1_P30 > 2.6))[[1]], tally(filter(projected_dams, RC1_P50 > 2.6))[[1]])
) %>%
mutate_at(vars(optimistic, current, pessimistic), .funs = list(perc = ~ ./tally(projected_dams)[[1]]))
# ...very low/low today and same risk level in the future
tally(filter(projected_dams, RC1 <= 2.6 & RC1_P50 <= 2.6))/tally(projected_dams) # 2632/3700 (71%)
# ...likely to face increase in risk
tally(filter(projected_dams, RC1_P50rc > 0.2))/tally(projected_dams) # 730/3700 (20%)
#### 4. FHReD & Change in Flooding (Pessimistic 2050) ----
## Number of dams
# ...exposed to medium to very high risk over time
tibble(
time = c(2020, 2030,2050),
optimistic = c(tally(filter(projected_dams, RC2 > 2.6))[[1]], tally(filter(projected_dams, RC2_O30 > 2.6))[[1]], tally(filter(projected_dams, RC2_O50 > 2.6))[[1]]),
current = c(tally(filter(projected_dams, RC2 > 2.6))[[1]], tally(filter(projected_dams, RC2_C30 > 2.6))[[1]], tally(filter(projected_dams, RC2_C50 > 2.6))[[1]]),
pessimistic = c(tally(filter(projected_dams, RC2 > 2.6))[[1]], tally(filter(projected_dams, RC2_P30 > 2.6))[[1]], tally(filter(projected_dams, RC2_P50 > 2.6))[[1]])
) %>%
mutate_at(vars(optimistic, current, pessimistic), .funs = list(perc = ~ ./tally(projected_dams)[[1]]))
# ...likely to face increase in risk
tally(filter(projected_dams, RC2_P50rc > 0.2))/tally(projected_dams) # 2315/3700 (63%)
#### 5. GRanD + FHReD & Scarcity (2050) + Flooding (2050) ----
## Number of dams
# ...projected to face medium to very high risk
tally(filter(all_dams, RC1_P50 > 2.6 & RC2_P50 > 2.6))/tally(all_dams) # 1157/6188 (19%)
# Risk combination
all_dams %>%
mutate(
Capacity_perc = sqrt(Capacity_perc)*15, Capacity_perc = if_else(Capacity_perc < 0.1, 0.1, Capacity_perc), # for visualisation purposes only
`Risk combination` = case_when(
RC1_P50 > 3.4 & RC2_P50 > 3.4 ~ "1-1 Scarcity High, Flooding High",
RC1_P50 > 3.4 & RC2_P50 > 2.6 & RC2_P50 <= 3.4 ~ "1-2 Scarcity High, Flooding Medium",
RC1_P50 > 3.4 & RC2_P50 <= 2.6 ~ "1-3 Scarcity High, Flooding Low",
RC1_P50 > 2.6 & RC1_P50 <= 3.4 & RC2_P50 > 3.4 ~ "2-1 Scarcity Medium, Flooding High",
RC1_P50 > 2.6 & RC1_P50 <= 3.4 & RC2_P50 > 2.6 & RC2_P50 <= 3.4 ~ "2-2 Scarcity Medium, Flooding Medium",
RC1_P50 > 2.6 & RC1_P50 <= 3.4 & RC2_P50 <= 2.6 ~ "2-3 Scarcity Medium, Flooding Low",
RC1_P50 <= 2.6 & RC2_P50 > 3.4 ~ "3-1 Scarcity Low, Flooding High",
RC1_P50 <= 2.6 & RC2_P50 > 2.6 & RC2_P50 <= 3.4 ~ "3-2 Scarcity Low, Flooding Medium",
RC1_P50 <= 2.6 & RC2_P50 <= 2.6 ~ "3-3 Scarcity Low, Flooding Low"
)
) %>%
select(Status:Basin, `Flooding risk in 2050` = RC2_P50, `Scarcity risk in 2050` = RC1_P50, `Risk combination`) %>%
group_by(`Risk combination`) %>%
summarise(
n=n(),
perc=round(n()/6188*100)
)
# Geographic distribution
all_dams %>%
filter(RC1_P50 > 2.6 & RC2_P50 > 2.6) %>%
group_by(Country) %>%
summarise(n=n()) %>%
arrange(desc(n))
all_dams %>%
filter(RC1_P50 > 2.6 & RC2_P50 > 2.6) %>%
arrange(desc(Capacity_perc)) %>%
select(Status, Name, Capacity, Capacity_perc, Use, Country, RC1_P50, RC2_P50)
#### 6. GRanD / FHReD & Biodiversity (2020) ----
mean(existing_dams$RC10);plotrix::std.error(existing_dams$RC10)
mean(projected_dams$RC10);plotrix::std.error(projected_dams$RC10)
## Number of dams
# ...already exposed to medium to very high risk today
tally(filter(existing_dams, RC10 > 2.6))/tally(existing_dams) # 1889/2488 (76%)
tally(filter(projected_dams, RC10 > 2.6))/tally(projected_dams) # 3431/3700 (93%)
existing_dams %>%
filter(RC10 > 2.6) %>%
group_by(Country) %>%
summarise(n=n(), cap=sum(Capacity)) %>%
arrange(desc(cap))
projected_dams %>%
filter(RC10 > 2.6) %>%
group_by(Country) %>%
summarise(n=n(), cap=sum(Capacity)) %>%
arrange(desc(cap))
#### 7. GRanD + FHReD & Scarcity (2050) + Biodiversity (2020) ----
## Number of dams
# ...already exposed to medium to very high risk today
tally(filter(all_dams, RC1_P50 > 2.6 & RC10 > 2.6))/tally(all_dams) # 1648/6188 (27%)
# Risk combination
all_dams %>%
mutate(
Capacity_perc = sqrt(Capacity_perc)*15, Capacity_perc = if_else(Capacity_perc < 0.1, 0.1, Capacity_perc), #only for visualization purposes!
`Risk combination` = case_when(
RC10 > 3.4 & RC1_P50 > 3.4 ~ "1-1 Biodiversity High, Scarcity High",
RC10 > 3.4 & RC1_P50 > 2.6 & RC1_P50 <= 3.4 ~ "1-2 Biodiversity High, Scarcity Medium",
RC10 > 3.4 & RC1_P50 <= 2.6 ~ "1-3 Biodiversity High, Scarcity Low",
RC10 > 2.6 & RC10 <= 3.4 & RC1_P50 > 3.4 ~ "2-1 Biodiversity Medium, Scarcity High",
RC10 > 2.6 & RC10 <= 3.4 & RC1_P50 > 2.6 & RC1_P50 <= 3.4 ~ "2-2 Biodiversity Medium, Scarcity Medium",
RC10 > 2.6 & RC10 <= 3.4 & RC1_P50 <= 2.6 ~ "2-3 Biodiversity Medium, Scarcity Low",
RC10 <= 2.6 & RC1_P50 > 3.4 ~ "3-1 Biodiversity Low, Scarcity High",
RC10 <= 2.6 & RC1_P50 > 2.6 & RC1_P50 <= 3.4 ~ "3-2 Biodiversity Low, Scarcity Medium",
RC10 <= 2.6 & RC1_P50 <= 2.6 ~ "3-3 Biodiversity Low, Scarcity Low"
)
) %>%
select(Status:Basin, `Scarcity risk in 2050` = RC1_P50, `Biodiversity risk in 2020` = RC10, `Risk combination`) %>%
group_by(`Risk combination`) %>%
summarise(
n=n(),
perc=round(n()/6188*100)
)
# Geographic distribution
all_dams %>%
filter(RC1_P50 > 2.6 & RC10 > 2.6) %>%
group_by(Country) %>%
summarise(n=n()) %>%
arrange(desc(n))
all_dams %>%
filter(RC1_P50 > 2.6 & RC10 > 2.6) %>%
arrange(desc(Capacity_perc)) %>%
select(Status, Name, Capacity, Capacity_perc, Use, Country, RC1_P50, RC2_P50)