Skip to content
Snippets Groups Projects
Commit 83f4aa9f authored by Schmidt Sebastian's avatar Schmidt Sebastian
Browse files

totholz.qmd erstellt, daten in struk_tot mit aktuellen zahlen geupdated und ergänzt

parent 531e8692
No related branches found
No related tags found
No related merge requests found
...@@ -342,30 +342,4 @@ ggplot((ver_vor_long %>% filter(Land == 'Brandenburg') %>% filter(Ba_Gruppen != ...@@ -342,30 +342,4 @@ ggplot((ver_vor_long %>% filter(Land == 'Brandenburg') %>% filter(Ba_Gruppen !=
scale_y_continuous(labels = scales::comma_format(big.mark = ".", decimal.mark = ","), scale_y_continuous(labels = scales::comma_format(big.mark = ".", decimal.mark = ","),
#breaks = seq(0, 1100000, by = 100000) #breaks = seq(0, 1100000, by = 100000)
) )
``` ```
\ No newline at end of file
## Quarto
Quarto enables you to weave together content and executable code into a
finished document. To learn more about Quarto see <https://quarto.org>.
## Running Code
When you click the **Render** button a document will be generated that
includes both content and the output of embedded code. You can embed
code like this:
```{r}
1 + 1
```
You can add options to executable code like this
```{r}
#| echo: false
2 * 2
```
The `echo: false` option disables the printing of code (only output is
displayed).
No preview for this file type
---
title: "Totholz"
subtitle: "Vorbereitung WS 08.07.24"
institution: "Landeskompetenzzentrum Forst Eberswalde"
author: "Torsten Wiebke und Sebastian Schmidt"
date: "`r Sys.Date()`"
bibliography: ../../LaTeX/bib/bibl.bib
csl: ../../LaTeX/bib/iso690-author-date-de.csl
editor: visual
format:
pdf:
documentclass: scrreprt #Komascript reprt
pdf-engine: pdflatex
keep-tex: true
# wenn nur PDF: in der Console: quarto::quarto_render("your_document.qmd", output_format = "pdf")
# quarto::quarto_render("bwi_interpretationsworkshop.qmd", output_format = "revealjs")
revealjs:
navigation-mode: vertical # ermölicht horizontale und vertikale Gliederung
slide-level: 5 # gibt Überschriftenebene an bis zu der eine eigene Folie erzeugt werden soll
incremental: false
slide-number: true
prefer-html: true
---
::: content-hidden
# Libraries und Daten
## Libraries laden
```{r librarys, include=FALSE}
library(readxl)
library(ggplot2)
library(stats)
library(corrplot)
library(tidyverse)
library(feather) # um Daten zu speichern
library(tidyr)
library(scales)
library(RColorBrewer) # Für eine breite Palette von Farben
library(patchwork) # um Diagramme nebeneinander darzustellen
library(knitr)
library(kableExtra)
library(xtable) # für LaTeX-Tabellen
library(quarto)
```
## Farben festlegen
```{r Farben, include=FALSE}
# Benutzerdefinierte Farben für die Layer
ba_farben <- c("Eiche (Quercus)" = "#ffffcc",
"Eiche" = "#ffffcc",
"Eichen-Typ" = "#ffffcc",
"Buche (Fagus)" = "#ccfe64",
"Buche" = "#ccfe64",
"Buchen-Typ" = "#ccfe64",
"Esche (Fraxinus)" = "#fed976",
"Eschen-Typ" = "#fed976",
"Ahorn (Acer)" = "#fd8d3c",
"sonst. Lb hoher Lebensdauer" = "#fc4e2a",
"andere Lb hoher Lebensdauer" = "#fc4e2a",
"Typ sonst. Laubbäume mit hoher Lebensdauer" = "#fc4e2a",
"Erle (Alnus)" = "#8c96c6",
"Erlen-Typ" = "#8c96c6",
"Birke (Betula)" = "#e0ecf4",
"Birken-Typ" = "#e0ecf4",
"sonst. Lb niedriger Lebensdauer" = "#88419d",
"andere Lb niedriger Lebensdauer" = "#88419d",
"Typ sonst. Laubbäume mit niedriger Lebensdauer"= "#88419d",
"alle Laubbäume" = "#ae017e",
"Fichte (Picea)" = "#7f7f7f",
"Fichte" = "#7f7f7f",
"Fichten-Typ" = "#7f7f7f",
"Tanne (Abies)" = "#a6bddb",
"Tanne" = "#a6bddb",
"Tannen-Typ" = "#a6bddb",
"Douglasie (Pseudotsuga)" = "#67a9cf",
"Douglasie" = "#67a9cf",
"Douglasien-Typ" = "#67a9cf",
"Kiefer (Pinus)" = "#e4ce4c",
"Kiefer" = "#e4ce4c",
"Kiefern-Typ" = "#e4ce4c",
"Lärche (Larix)" = "#f4a6a4",
"Lärche" = "#f4a6a4",
"Lärchen-Typ" = "#f4a6a4",
"alle Nadelbäume" = "#02818a",
"Typ mit mehreren gleichrangigen Baumarten" ="#006d2c",
"Lücke" = "#dcdcdc",
"Blöße" = "#edf8fb",
"Nichtholzboden" = "#b2e2e2",
"Holzboden" = "#66c2a4",
"bestockter Holzboden" = "#2ca25f",
"Wald" = "#006d2c",
"stehend, ganzer Baum" = "goldenrod1",
"stehend, Bruchstück (Höhe ab 130 cm)" = "goldenrod2",
"stehend" = "goldenrod3",
"liegend, ganzer Baum mit Wurzelanlauf" = "darkseagreen1",
"liegend, Stammstück mit Wurzelanlauf" = "darkseagreen2",
"liegend, Teilstück ohne Wurzelanlauf" = "darkseagreen3",
"liegend" = "darkseagreen4",
"Wurzelstock (Höhe < 130 cm)" = "#88419d",
"Abfuhrrest (aufgeschichtet)" = "#ae017e",
"alle Totholztypen" = "#67a9cf"
)
```
## [**Datenimport**]
### Totholzzustand {.hidden .unnumbered .unlisted}
```{r imp_struktur_tot, include=FALSE}
tot_sheet_names <- excel_sheets("data/struktur_tot.xlsx")
tot <- lapply(tot_sheet_names, function(sheet) {
read_excel("data/struktur_tot.xlsx", sheet = sheet, skip = 5, na = c("NaN"))
})
names(tot) <- tot_sheet_names
```
## Auswertung
### Vergleich Totholzvorrat 13-22
```{r totvorrat13_22, include=FALSE}
# Daten Vorbereiten
# Totholzvorrat BB Vergleich 13-22
totvorrat_long_13_22 <- tot$bb_tot_typ_13_22 %>%
filter(Eigentumsart == "alle Eigentumsarten 2013"|Eigentumsart == "alle Eigentumsarten 2022") %>%
pivot_longer(cols = c("alle Totholztypen"),
names_to = "Totholztyp",
values_to = "Totholzvorrat")
```
```{r totvorrat13_22_bar, echo=FALSE}
# Bar Totholzvorrat BB Vergleich 13-22
# Plot erstellen als Säulendiagramm für 2013 & 2022
totvorrat_13_22 <- ggplot(totvorrat_long_13_22, aes(x = Eigentumsart, y = Totholzvorrat)) +
geom_bar(stat = "identity", fill = "dodgerblue3", show.legend = FALSE) + # Set custom color
geom_text(aes(label = paste0(round(Totholzvorrat, 1), " m³/ha")),
vjust = 0.5, hjust = 0.5, color = "white", size = 4.5,
position = position_stack(vjust = 0.5), fontface = "bold") + # Center the labels
labs(x = "Inventur",
y = "Totholzvorrat [m³/ha]") +
ggtitle("Vergleich der Totholzvorräte in m³/ha in Brandenburg \n LWI 2013 / BWI 2022") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(margin = margin(b = 20)),
plot.title.position = "plot",
legend.position = "none") +
scale_x_discrete(labels = c("alle Eigentumsarten 2013" = "LWI 2013", "alle Eigentumsarten 2022" = "BWI 2022")) +
scale_y_continuous(labels = scales::comma_format(big.mark = ".", decimal.mark = ","),
breaks = seq(0, 18, by = 2), # Adjust breaks as needed
limits = c(0, 18)) # Set y-axis limit
totvorrat_13_22
```
Der Totholzvorrat in Brandenburg hat von der Landeswaldinventur 2013 zur Bundeswaldinventur 2022 um 6,1 m³/ha zugenommen.
In der Veränderungsrechung (welche nur Punkte im Veränderungsnetz mit einbezieht) liegt der Anstieg bei 6,4 m³/ha
### Vergleich Totholzvorrat nach Laub-/Nadel-/Eichenholz
```{r totvorrat13_22_bag, include=FALSE}
# Daten Vorbereiten
# Totholzvorrat Baumartengruppe BB Vergleich 13-22
#str(tot$bb_tot_art_13_22)
totvorrat_bag_long_13_22 <- tot$bb_tot_art_13_22 %>%
filter(Eigentumsart == "alle Eigentumsarten 2013" | Eigentumsart == "alle Eigentumsarten 2022") %>%
pivot_longer(cols = -c(Jahr,Eigentumsart, Einheit,"alle Baumartengruppen von Totholz"),
names_to = "Baumartengruppe",
values_to = "Totholzvorrat")
```
```{r totvorrat13_22_bag_stackbar, echo=FALSE}
# Stacked Bar Totholzvorrat Baumartengruppe BB Vergleich 13-22
#Prozentwert ausrechnen
totvorrat_bag_long_13_22 <- totvorrat_bag_long_13_22 %>%
arrange(Totholzvorrat) %>%
group_by(Eigentumsart) %>%
mutate(Percentage = 100 * Totholzvorrat / sum(Totholzvorrat)) %>%
ungroup()
#sortieren nach Menge
totvorrat_bag_long_13_22 <- arrange(totvorrat_bag_long_13_22, Totholzvorrat)
# Custom colors
custom_colors <- c("dodgerblue3", "forestgreen", "firebrick")
# Plot erstellen als gestapeltes Säulendiagramm für 2013 & 2022
totvorrat_bag_13_22 <- ggplot(totvorrat_bag_long_13_22, aes(x = Eigentumsart, y = Totholzvorrat, fill = reorder(Baumartengruppe, Totholzvorrat, FUN = sum))) +
geom_bar(stat = "identity", position = "stack") +
geom_text(aes(label = paste0(round(Totholzvorrat, 1), " m³/ha (", round(Percentage, 1), "%)")),
vjust = 0.5, hjust = 0.5, color = "white", size = 3.5,
position = position_stack(vjust = 0.5), fontface = "bold") +
labs(x = "Inventur",
y = "Totholzvorrat [m³/ha]") +
ggtitle("Vergleich der Totholzvorräte in m³/ha nach Baumartengruppe in Brandenburg \n LWI 2013 / BWI 2022") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(margin = margin(b = 20)),
plot.title.position = "plot") +
#legend.position = "none") +
scale_x_discrete(labels = c("alle Eigentumsarten 2013" = "LWI 2013", "alle Eigentumsarten 2022" = "BWI 2022")) +
guides(fill = guide_legend(title = "Baumartengruppe", title.position = "top")) +
scale_fill_manual(values = custom_colors) +
scale_y_continuous(labels = scales::comma_format(big.mark = ".", decimal.mark = ","),
breaks = seq(0, 18, by = 2), # Adjust breaks as needed
limits = c(0, 18)) # Set y-axis limit
totvorrat_bag_13_22
```
### Vergleich Totholzvorrat und Totholztyp 12-22
```{r totvorrat12_22_typ_stackbar, echo=FALSE}
# Stacked bar Vergleich Totholzvorrat 12-22
totvorrat_typ_long_2012_2022 <- arrange(totvorrat_typ_long_2012_2022, Totholzvorrat)
# Plot erstellen als gestapeltes Säulendiagramm - geordnet mit Flächenangaben - für 2012 & 2022
totvorrat12_22_typ_stackbar <- ggplot(totvorrat_typ_long_2012_2022, aes(x = Eigentumsart, y = Totholzvorrat, fill = reorder(Totholztyp, Totholzvorrat, FUN = sum))) +
geom_bar(stat = "identity", position = "stack") +
# scale_fill_manual() + # Farben manuell festlegen +
labs(x = "Totholztyp",
y = "Totholzvorrat [m³/ha]") +
ggtitle("Vergleich der Totholzvorräte nach Totholztyp in m³/ha\n über alle Eigentumsarten in Brandenburg - BWI2012 / BWI2022") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(margin = margin(b = 20)),
plot.title.position = "plot") +
guides(fill = guide_legend(title = "Totholztyp", title.position = "top")) +
scale_y_continuous(labels = scales::comma_format(big.mark = ".", decimal.mark = ","),
breaks = seq(0, sum(totvorrat_typ_long_2012_2022$Totholzvorrat), by = 2))
totvorrat12_22_typ_stackbar
```
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment