generated from NINAnor/NINA-ebook-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
study-area.qmd
400 lines (318 loc) · 11.8 KB
/
study-area.qmd
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# Study area and trenching data {#sec-area}
In this project we will use data from Levanger in central Norway. This area was part of the pilot study to identify mire trenches in Norway based on LiDAR [@jansson2024] (see also @sec-background).
```{r setup}
#| warning: false
#| error: false
#| include: false
library(sf)
library(tidyverse)
library(basemaps)
library(stars)
library(ggpubr)
options(scipen = 999)
dir <- substr(getwd(), 1,2)
# conditional path
path1 <- ifelse(dir == "C:", "R:/", "/data/R/")
```
```{r data}
#| code-fold: true
#| code-summary: "Read shape file and convert to gpkg"
#| eval: false
path <- "41201785_okologisk_tilstand_2022_2023/data/grofter/Kolstad"
lev <- sf::read_sf(paste0(path1, path, "/LevangerGroftPolygon.shp")) |>
sf::st_make_valid()
lev |> sf::st_write("data/lev.gpkg")
```
```{r data2}
#| code-fold: true
#| code-summary: "Read data"
lev <- sf::read_sf("data/lev.gpkg")
```
```{r stats}
#| code-fold: true
#| code-summary: "Calculate study extent"
lev_bb <- sf::st_bbox(lev)
myx <- unname(round(lev_bb["xmax"] - lev_bb["xmin"]))
myy <- unname(round(lev_bb["ymax"] - lev_bb["ymin"]))
```
The study area is `r myx` 𝖷 `r myy` meters, or `r round(myx*myy/10^6)` km^2^.
```{r basemapSetup}
#| code-fold: true
#| code-summary: "Set up basemap"
basemaps::set_defaults(map_service = "osm", map_type = "topographic")
lev_t <- lev |>
st_transform(3857)
```
```{r fig-map1}
#| code-fold: true
#| code-summary: "Make map"
#| fig-cap: |
#| "Map of study area in Levanger, central Norway, showing trenched mires i purple.
#| Note that the colored polygon borders exagerrate the area of the trenches."
#| cache: true
#| message: false
#| warning: false
ggplot() +
basemap_gglayer(sf::st_bbox(lev_t)) +
scale_fill_identity() +
coord_sf() +
geom_sf(data = lev_t,
fill = "purple",
color = "purple") +
theme_bw()
```
Let's zoom in on an area just north of Tomtvatnet, and overlay the trenches data with a map of open mires [@bakkestuen2023].
```{r zoombbox}
#| code-fold: true
#| code-summary: "Creat new bbox"
#| warning: false
bbox_new <- st_bbox(lev) # current bounding box
xrange <- bbox_new$xmax - bbox_new$xmin # range of x values
yrange <- bbox_new$ymax - bbox_new$ymin # range of y values
bbox_new[1] <- bbox_new[1] + (0.3 * xrange) # xmin - left
bbox_new[3] <- bbox_new[3] - (0.5 * xrange) # xmax - right
bbox_new[2] <- bbox_new[2] + (0.4 * yrange) # ymin - bottom
bbox_new[4] <- bbox_new[4] - (0.5 * yrange) # ymax - top
lev_crop <- lev |>
sf::st_crop(bbox_new)
```
```{r readMire}
#| code-fold: true
#| code-summary: "Read mire data"
#| eval: false
# I took the gdb file in the same folder and opened it in arcgis pro
# and exported a section of it as geoTIFF
# Raster GBD is not readable in R with GDAL <3.7
path <- "41201785_okologisk_tilstand_2022_2023/data/Myrmodell/myrmodell_levanger.tif"
mire90 <- stars::read_stars(paste0(path1, path)) |>
st_crop(lev_bb) |>
setNames("prob") |>
mutate(prob = case_when(
prob > 900 ~ 1,
TRUE ~ NA
))
stars::write_stars(mire90, "data/mire_levanger_reclassified90.tif")
saveRDS(mire90, "data/mire_levanger_reclassified90.rds")
mire70 <- stars::read_stars(path) |>
st_crop(lev_bb) |>
setNames("prob") |>
mutate(prob = case_when(
prob > 700 ~ 1,
TRUE ~ NA
))
stars::write_stars(mire70, "data/mire_levanger_reclassified70.tif")
saveRDS(mire70, "data/mire_levanger_reclassified70.rds")
mire50 <- stars::read_stars(path) |>
st_crop(lev_bb) |>
setNames("prob") |>
mutate(prob = case_when(
prob > 500 ~ 1,
TRUE ~ NA
))
stars::write_stars(mire50, "data/mire_levanger_reclassified50.tif")
saveRDS(mire50, "data/mire_levanger_reclassified50.rds")
mire10 <- stars::read_stars(path) |>
st_crop(lev_bb) |>
setNames("prob") |>
mutate(prob = case_when(
prob > 100 ~ 1,
TRUE ~ NA
))
stars::write_stars(mire10, "data/mire_levanger_reclassified10.tif")
saveRDS(mire10, "data/mire_levanger_reclassified10.rds")
```
```{r}
#| code-fold: true
#| code-summary: "Read mire data"
#90% probability
mire90 <- readRDS("data/mire_levanger_reclassified90.rds")
mire90_crop <- mire90 |>
st_crop(st_bbox(lev_crop))
#10% probability
mire10 <- readRDS("data/mire_levanger_reclassified10.rds")
mire10_crop <- mire10 |>
st_crop(st_bbox(lev_crop))
```
```{r fig-map2}
#| code-fold: true
#| code-summary: "Create map"
#| cache: true
#| warning: false
#| fig-cap: |
#| "Zoomed in version of the previous map showing systematic trenching,
#| but also more sporadic trenches that might be errors in the model.
#| The red areas are open mires with 10% probability.
#| Yellow areas are mires with 90% probability. From areal photos, the 10% probability seem to match best.
#| Note in any case that most of the trenches are located in
#| other nature types, mosty forests."
ggplot() +
geom_sf(data = lev_crop,
fill = "purple",
color = "purple") +
geom_stars(data = mire10_crop,
downsample = 0,
fill = "red",
na.action = na.omit,
alpha=.7)+
geom_stars(data = mire90_crop,
downsample = 0,
fill = "yellow",
na.action = na.omit,
alpha=.7)+
theme_bw()
```
The trenches model originally results in a raster with a continuous probability value for the occurrence of a trench in each 1 𝖷 1 m cell. What I show above (@fig-map1, @fig-map2) is a version of this data where a threshold value of 90% for the probabilities turn it into presence-absence data in the shape of polygons.
## Adding AR5
The open wetlands, shown as red areas in @fig-map2, are largely laying outside of the systematically trenched areas. This can be because the trenched areas, which may have been open mire to begin with, now are overgrown with trees. The map of open mires is in way trained to find areas that are not trenched, so no wonder if the ecosystem condition looks good in these areas. Instead I think we should include forested mires in the Ecosystem Type (ET). We can use the mire class in the AR5 maps in addition to the open mires map. AR5 underestimates the total mire area, but it probably includes more forested mires. Another alternative would be to use the new Ecosystem Map of Norway [@strand2023], but this uses AR50, i.e. as coarser generalization of AR5.
```{r ar5}
#| code-fold: true
#| code-summary: "Prepare AR5 data"
#| eval: false
#| include: false
ar5_path <- "GeoSpatialData/Topography/Norway_FKB/Original/FKB-AR5 FGDB-format/Basisdata_50_Trondelag_25832_FKB-AR5_FGDB.gdb"
st_layers(paste0(path1, ar5_path))
# this takes a while and should be done on the server
ar5 <- sf::read_sf(paste0(path1, ar5_path),
layer = "fkb_ar5_omrade")
ar5_crop <- ar5 |>
st_crop(bbox_new)
ar5_crop <- ar5_crop |>
mutate(Arealtype = case_match(
arealtype,
"60" ~ "Myr",
"12" ~ "Samferdsel",
"21" ~ "Fulldyrka mark",
"23" ~ "Innmarksbeite",
"30" ~ "Barskog",
"50" ~ "Åpen mark",
"81" ~ "Ferskvann",
.default = arealtype
))
ar5_union <- ar5_crop |>
group_by(Arealtype) |>
summarise()
saveRDS(ar5_union, "data/ar5.rds")
```
```{r fig-ar5}
#| fig-cap: |
#| "AR5 overlayed with the mire trenches data.
#| AR5 classifies most of the systamtically trenched peatlands as mire,
#| and some as forest.
#| code-fold: true
#| code-summary: "Read AR5 and plot"
ar5 <- readRDS("data/ar5.rds")
ggplot() +
geom_sf(data = ar5,
aes(fill = Arealtype)) +
geom_sf(data = lev_crop,
fill = "yellow",
color = "yellow")
```
Let's separate out the areas that are mire in AR5, but not in the open mire map,
and see if adding these areas make a difference. Of coarse, we are only looking at
a very small spatial extent here, and it is not representative for all the
differences between AR5 and the opne mire map, but still.
```{r makeDatasetsAndPlots}
#| code-fold: true
#| code-summary: "Filter data"
#| warning: false
# make the ecosystem delineation map into polygons
mire <- st_as_sf(mire10_crop, merge = T)
mire_gg <- ggplot(data = mire)+
geom_sf(fill = "blue")+
labs(title = "Open mire model")
# Filter out the mire part of AR5
ar5_myr <- ar5 |>
filter(Arealtype == "Myr") |>
st_cast("POLYGON")
ar5_myr_gg <- ggplot(data = ar5_myr)+
geom_sf(fill = "cyan4")+
labs(title = "AR5")
# Take out the open mire part of AR5 (leaving the forested peatlands)
st_erase = function(x, y) st_difference(x, st_union(st_combine(y)))
ar5_nonOpen <- ar5_myr |>
st_erase(mire)
# Take out the AR5 part of the open mire model
only_open <- mire |>
st_erase(ar5_myr) |>
st_cast("MULTIPOLYGON") |>
st_cast("POLYGON")
only_open_gg <- ggplot(data = only_open)+
geom_sf(fill = "purple")+
labs(title = "Open mires not in AR5")
ar5_nonOpen_gg <-
ggplot(data = ar5_nonOpen)+
geom_sf(fill = "orange")+
labs(title = "AR5 minus open mires")
# check that polygons dont overlap
check <-
ggplot(data = ar5_nonOpen)+
geom_sf(fill = "red",
alpha=.5)+
geom_sf(data = mire,
fill = "blue",
alpha=.5)+
labs(title = "AR5 (red) and open mires\n (blue) combined")
# combine into new mire map
# This first attempt with st_union produces way to many small polygon
#peatlands <- ar5_myr |>
# st_union(mire) |>
# st_cast("MULTIPOLYGON") |>
# st_cast("POLYGON")
#but this works:
peatlands <- ar5_myr |>
st_join(mire) |>
st_intersection()
peatlands_gg <- ggplot(data = peatlands)+
geom_sf(fill = "green")+
labs(title = "AR5 + open mires")
```
```{r fig-mireExtents}
#| code-fold: true
#| code-summary: "Plot data"
#| fig-cap: |
#| "Different combinations of the open mire model
#| and the AR5 mire category."
ggarrange(mire_gg,
ar5_myr_gg,
ar5_nonOpen_gg,
only_open_gg,
check,
peatlands_gg,
ncol=2, nrow=3)
```
```{r savefiles}
#| include: false
#| eval: false
save(
mire10_crop,
lev_crop,
ar5_nonOpen,
peatlands,
file = "data/study-area-files.RData"
)
```
## Ecosystem delineation {#sec-delineation}
We presented a study area that is practically square (@fig-map1).
However, for the purpose of an ecosystem condition account or assessment,
this area needs to be partitioned into unique and non-overlapping ecosystems,
and our indicator needs to address the ecosystem condition the target ecosystem explicitly.
The ecosystem that this indicator is aimed at is wetlands, or _våtmark_ in Norwegian.
We might therefore need to mask our spatial data at some stage in order to exclude
trenches identified in other ecosystems.
However, this is problematic for several reasons.
We do not have a very precise ecosystem delineation map for wetlands,
and it is not yet clear if the ecosystem should be defined as all types of wetlands,
or just open wetlands. In the case of the latter, we have a quite good ecosystem map that we can use (@fig-map2). But by excluding everything that is not open mire,
we automatically exclude wetlands, or previous wetlands, that
have become forested due to the lowered water table that comes from trenching.
In other words, we exclude the areas that are in the worst condition.
From @fig-map2 we can see that this is a very common scenario.
Alternatively, we can use things like AR5, or a combination of the two (@fig-mireExtents).
When it comes to updating the indicator in the future (see @sec-update),
we will be in the case that more and more trenched wetland becomes classified as other
nature types, mainly forests, because that is what happens when you trench a mire.
As a consequence, the indicator values will look better and better over time,
reflection the land use change and the associated loss of the areas in worst condition. This is a well known issue in ecosystem accounting (ref Jacobson).
We recommend for this indicator to delineate the nature type as open mires in the open mire model [@bakkestuen2023], in combination with mires in AR5 (@fig-mireExtents; last pane).
# References {.unnumbered}