Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reg al #100

Closed
wants to merge 71 commits into from
Closed
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
eaa8dc8
regeneration: toevoeging van mean_nr_of_trees_ha
leymanan Jun 9, 2021
81bf81a
calc_reg_corte_area_XX:
leymanan Jun 9, 2021
32934b7
load_data_regeneration: naam subplot ook inladen
leymanan Jun 9, 2021
650340f
load_veg en load_herblayer: subplot-naam toegevoegd
leymanan Jun 10, 2021
f38d0d0
calc_veg_CA_species: correctie percentage plots met vegetatie (n_subp…
leymanan Jun 10, 2021
3ea45ae
calc_veg_plot:
leymanan Jun 10, 2021
1cbfbc8
calc_reg en calc_veg functies: subplot bij documentatie toegevoegd
leymanan Jun 10, 2021
02765da
calc_veg_ca_species: aanpassing browseindex (gewijzigde LU-list)
leymanan Jun 10, 2021
f579319
calc_veg_core_area_species: data_vegetation toegevogd bij argument
leymanan Jun 10, 2021
75d9833
load_plotinfo uitgebreid (+ manual)
leymanan Jun 10, 2021
eb9680b
load_plotinfo uitgebreid (+ manual)
leymanan Jun 10, 2021
83616a9
calc_veg_core_area: foutje (data_veg_CA vergeten)
leymanan Jun 10, 2021
2cfb7ef
problem
leymanan Jun 10, 2021
08469b5
problem
leymanan Jun 10, 2021
3617bb8
load_plotinfo: '-' vergeten
leymanan Jun 11, 2021
7184e01
read_forresdat:
leymanan Jun 11, 2021
520d2e4
read_forresdat
leymanan Jun 11, 2021
d5aed27
load_forresdat: aanpassing documentatie nalv uitbreiding plotinfo
leymanan Jun 11, 2021
c03a744
calc_veg_plot: variabele "cumm_herb_coverage_class_average_perc" teru…
leymanan Jun 11, 2021
93c7824
load-data_dendro: oldid toegevoegd
leymanan Jun 11, 2021
1d8ad15
create_unique_tree_id: periode 1 géén old_id's anders werkt code niet…
leymanan Jun 11, 2021
4e9e2d3
load_data_shoots: mogelijkheid om extra variables toe te voegen
leymanan Jul 15, 2021
bee94a6
load_data_dendrometry: "Trees." vergeten
leymanan Jul 15, 2021
78f05c6
load_data_shoots: extra "_shoots" toegeveogd bij iufro klasses: makke…
leymanan Jul 15, 2021
caf8d29
load_data_reg/veg/herbl: subplot_name verwijderd
leymanan Jul 16, 2021
2df7c3d
Update R/calculate_regeneration_core_area_height_species.R
leymanan Jul 20, 2021
9a99dd0
calc_reg_core_area: aanpassingen cfr Els (mutate ipv left_join)
leymanan Jul 20, 2021
2725cc7
calc_veg_core_area: cfr regeneration ook left_join vervangen door mutate
leymanan Jul 20, 2021
c1dce72
Update R/create_unique_tree_id.R
leymanan Jul 22, 2021
b4dbd4e
Update R/calculate_regeneration_plot_height.R
leymanan Jul 22, 2021
8d5ee21
Update R/calculate_regeneration_plot_height_species.R
leymanan Jul 22, 2021
70adc6e
Update R/calculate_vegetation_plot.R
leymanan Jul 22, 2021
04e1684
Update R/calculate_regeneration_plot.R
leymanan Jul 22, 2021
1efc593
fixes issue #90
ElsLommelen Aug 17, 2021
ab720a6
update documentation
ElsLommelen Aug 17, 2021
6fe8868
Merge pull request #93 from inbo/issue90
leymanan Mar 2, 2022
9c28d4d
Merge branch 'master' of https://github.com/inbo/forrescalc into reg_AL
leymanan Mar 2, 2022
abe2e4e
Merge branch 'statistics-and-other-issues' into reg_AL
leymanan Mar 25, 2022
3fb6815
na vgl van branch reg_Al en branch statistics nog 4 files aangepast:
leymanan Mar 25, 2022
a25d5d7
compose_stem_data: ook info mbt "remark" meenemen van layer shoots
leymanan Mar 28, 2022
d0be3a8
add height models to script Main.R
ElsLommelen Mar 29, 2022
2f8b2fc
Merge pull request #101 from inbo/update-Main-script
leymanan Mar 30, 2022
86340ce
Update R/read_forresdat.R
leymanan Apr 7, 2022
618bce4
Update R/read_forresdat.R
leymanan Apr 7, 2022
c144e8f
load & calc_veg_plot:
leymanan Apr 7, 2022
9e47057
compose_stem_data:
leymanan Apr 7, 2022
c430e85
Main.R: verwijderen code voor niet opgemeten deadwood.
leymanan Apr 7, 2022
afd79e7
aanpassingen nalv lint_package, vooral inkorten van lijnen
leymanan Apr 7, 2022
923ae6a
load_data_veg: dubbele aanmaak mid_cover
leymanan Apr 7, 2022
7ec13e6
load_data_veg, load_data_herblayer, calc_veg_plot:
leymanan Apr 7, 2022
b3767ac
load_data_veg: typo
leymanan Apr 7, 2022
04e28fd
calc_veg_plot: "date_vegetation" toegevoegd
leymanan Apr 7, 2022
92b2190
load_data_herblayer: typo
leymanan Apr 7, 2022
4afcf78
DAS_indicator.Rmd: verwijderen van blanco's op einde regels (cfr lint)
leymanan Apr 7, 2022
e9c6067
load_data_reg: "year_main_survey" verwijderd om verwarring te voorkomen.
leymanan Apr 7, 2022
7806699
load_data_veg: year_main_survey bij voorkeur obv data_vegetation, enk…
leymanan Apr 7, 2022
acbf7c9
load_plotinfo: date_dendro_1986 toegevoegd
leymanan Apr 7, 2022
0200341
calc_var_stem_level: height trees minimaal 1.3m
leymanan Apr 8, 2022
18f1758
removal of variable "nr_of_regeneration_ha" (or "nr_established_ha" a…
leymanan Jul 13, 2022
c3759ee
calc_reg_plot: error: "mean" instead of "sum" used
leymanan Jul 13, 2022
20901af
calc_regeneration_functions: extra info about confidence interval
leymanan Jul 13, 2022
0dba594
5 calc_reg_functions: info on "return" adjusted for the removal of nr…
leymanan Jul 13, 2022
7d3f221
sum_intervals: uci was NaN ipv 0 daar waar mean en lci wél 0 waren.
leymanan Jul 15, 2022
af84947
calculate_regeneration_plot &
leymanan Jul 15, 2022
a4ee087
calc_reg_plot_corearea_species: klein foutje (mean ipv sum)
leymanan Jul 15, 2022
3dbef1a
Update R/calc_variables_stem_level.R
leymanan Nov 29, 2022
a7c6e73
Update R/compose_stem_data.R
leymanan Nov 29, 2022
de4b312
Update R/compose_stem_data.R
leymanan Nov 29, 2022
22c606a
compose_stem_data: uitleg ivm parameter "extra variables" aangepast c…
leymanan Nov 29, 2022
2cdc15a
Merge branch 'reg_AL' of github.com:inbo/forrescalc into reg_AL
leymanan Nov 29, 2022
4fab058
remove mid_cover from load_data_vegetation()
ElsLommelen Nov 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion R/calculate_regeneration_core_area_height_species.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' @return dataframe with columns plot, species, year, height,
#' number_of_subplots_with_regeneration, perc_subplots_with_regeneration,
#' rubbing_damage_perc, nr_of_regeneration_ha (in case exact numbers are
#' observed), mean_number_of_regeneration_ha (in case intervals are observed),
#' observed), mean_number_of_regeneration_ha,
#' lci_number_of_regeneration_ha, uci_number_of_regeneration_ha and
#' approx_nr_regeneration_ha.
#'
Expand All @@ -34,9 +34,11 @@
#'
calculate_regeneration_core_area_height_species <- function(data_regeneration) {
by_plot_species <- data_regeneration %>%
group_by(.data$plot_id, .data$period) %>%
mutate(
n_subplots = n_distinct(.data$subplot_id)
) %>%
ungroup() %>%
group_by(
.data$plot_id, .data$year, .data$period, .data$height_class,
.data$species, .data$plotarea_ha
Expand Down
2 changes: 2 additions & 0 deletions R/calculate_regeneration_core_area_species.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#'
calculate_regeneration_core_area_species <- function(data_regeneration) {
by_plot_species <- data_regeneration %>%
group_by(.data$plot_id, .data$period) %>%
mutate(
n_subplots = n_distinct(.data$subplot_id),
nr_established_ha =
Expand Down Expand Up @@ -62,6 +63,7 @@ calculate_regeneration_core_area_species <- function(data_regeneration) {
ifelse(is.na(.data$subcircle) | .data$subcircle == "A1",
.data$approx_nr_regeneration / .data$plotarea_ha, NA)
) %>%
ungroup() %>%
group_by(
.data$plot_id, .data$year, .data$period, .data$species
) %>%
Expand Down
2 changes: 1 addition & 1 deletion R/calculate_regeneration_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#'
#' @inheritParams calculate_regeneration
#'
#' @return dataframe with columns plot, year, period, number_of_tree_species,
#' @return dataframe with columns plot, subplot, year, period, number_of_tree_species,
#' nr_established_ha, nr_seedlings_ha, mean_number_established_ha,
#' lci_number_established_ha, uci_number_established_ha,
#' mean_number_seedlings_ha, lci_number_seedlings_ha, uci_number_seedlings_ha,
Expand Down
4 changes: 2 additions & 2 deletions R/calculate_regeneration_plot_height.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#'
#' @inheritParams calculate_regeneration
#'
#' @return dataframe with columns plot_id, year, period, height_class,
#' @return dataframe with columns plot, subplot, year, period, height_class,
#' number_of_tree_species, rubbing_damage_perc,
#' nr_of_regeneration_ha (in case exact numbers are observed),
#' mean_number_of_regeneration_ha (in case intervals are observed),
#' mean_number_of_regeneration_ha,
#' lci_number_of_regeneration_ha, uci_number_of_regeneration_ha and
#' approx_nr_regeneration_ha.
#'
Expand Down
2 changes: 1 addition & 1 deletion R/calculate_regeneration_plot_height_species.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#'
#' @inheritParams calculate_regeneration
#'
#' @return dataframe with columns plot, year, height_class, species,
#' @return dataframe with columns plot, subplot, year, height_class, species,
#' rubbing_damage_perc, nr_of_regeneration_ha (in case exact numbers are
#' observed), mean_number_of_regeneration_ha (in case intervals are observed),
#' lci_number_of_regeneration_ha, uci_number_of_regeneration_ha and
Expand Down
8 changes: 5 additions & 3 deletions R/calculate_vegetation_core_area_species.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
#' @importFrom dplyr %>% group_by n_distinct summarise ungroup
#' @importFrom rlang .data
#'
calculate_vegetation_core_area_species <- function(data_herblayer) {
calculate_vegetation_core_area_species <- function(data_herblayer, data_vegetation) {
by_core_area_species <- data_herblayer %>%
group_by(.data$plot_id, .data$period) %>%
mutate(
n_subplots = n_distinct(.data$subplot_id)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ElsLommelen : hier nog een foutje ontdekt: n_subplots zou moeten bepaald worden obv data_vegetation, want in data_herblayer zitten enkel de subplots waar minimum één soort waargenomen werd. In data_vegetation zitten alle subplots.
(Bij regeneration wordt n_subplots bepaald obv de regeneration layer, wat wel correct is)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem dito in calc_veg_core_area_height_species

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Euh, dit is een vreemde situatie die je best nog even bekijkt, @leymanan :

Blijkbaar heb je in deze functie het argument data_vegetation toegevoegd zonder het te gebruiken (zie hier), en ook zonder de documentatie hieraan aan te passen. Maar dit argument lijkt me niet nodig te zijn? Mag dit terug weg? (Zie eerst hieronder.)

@ElsLommelen : hier nog een foutje ontdekt: n_subplots zou moeten bepaald worden obv data_vegetation, want in data_herblayer zitten enkel de subplots waar minimum één soort waargenomen werd. In data_vegetation zitten alle subplots.
(Bij regeneration wordt n_subplots bepaald obv de regeneration layer, wat wel correct is)

De subplot_id die opgehaald wordt in load_data_herblayer(), is afkomstig uit tabel Vegetation uit de databank (zie hier), dus ik ga ervan uit dat dit wel in orde is?

idem dito in calc_veg_core_area_height_species

Functie calc_veg_core_area_height_species() zie ik nergens staan, kan het zijn dat die nooit toegevoegd is? Moet die toegevoegd worden?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in deze commit zie ik anders wel gebruik van data_vegetation?

ik denk nog steeds dat dit nodig is.

De subplot_id die opgehaald wordt in load_data_herblayer(), is afkomstig uit tabel Vegetation uit de databank (zie hier), dus ik ga ervan uit dat dit wel in orde is?

daar wordt een inner-join gemaakt tss Herblayer en Vegetation: dus als er een bepaald record niet aanwezig is in Herblayer (wegens geen enkele soort aanwezig), dan wordt die subplot_id niet opgepikt ...

Functie calc_veg_core_area_height_species() zie ik nergens staan, kan het zijn dat die nooit toegevoegd is? Moet die toegevoegd worden?

Height wordt enkel bij regeneration gebruikt (calculate_regeneration_core_area_height_species.R bestaat)
calc_veg_core_area_height_species() niet nodig ;-)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in deze commit zie ik anders wel gebruik van data_vegetation?

Dat is een commit van meer dan 2 jaar geleden, en intussen is de code blijkbaar veranderd en is het inladen van data_vegetation overbodig geworden. Ik heb even gezocht waar die data_vegetation gewist is, maar ik kan het niet terugvinden. Ik vermoed dat we dat we op een bepaald moment beslist hebben om die subplot_id in load_data_herblayer() op te halen om gebruikers niet te verplichten om voor calculate_vegetation_core_area_species() behalve load_data_herblayer() ook load_data_vegetation() te moeten opladen enkel om dat ene item subplot_id op te laden. Maar blijkbaar zijn we daarbij vergeten om de join in load_data_herblayer() aan te passen.

daar wordt een inner-join gemaakt tss Herblayer en Vegetation: dus als er een bepaald record niet aanwezig is in Herblayer (wegens geen enkele soort aanwezig), dan wordt die subplot_id niet opgepikt ...

Zal ik er daar een left join van maken? Dus Plots inner join Vegetation LEFT JOIN Herblayer. (Vermits het access is, zal ik ook nog met de haakjes moeten spelen enz., maar ik neem aan dat je wel weet wat ik bedoel.) Dit lijkt me een veel minder ingrijpende aanpassing als het functioneel toevoegen van data_vegetation in calculate_vegetation_core_area_species().

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ja, dat is inderdaad betere oplossing (left join bij load data herblayer)

Maar indien mogelijk misschien wel survey_veg = TRUE ergens meenemen?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, opgelost in commit cf90684 (left join in Access ziet er wel iets complexer uit dan gewone SQL omdat hier de mix van inner join en left join in Access niet kan zonder met een subquery te werken).
Die selectie survey_veg = TRUE gebeurt blijkbaar hier in load_data_herblayer(), dus dat zou ook in orde moeten zijn.

) %>%
ungroup() %>%
group_by(
.data$plot_id, .data$year, .data$period, .data$species
) %>%
Expand All @@ -39,13 +41,13 @@ calculate_vegetation_core_area_species <- function(data_herblayer) {
all(is.na(.data$browse_index_id)),
NA,
sum(!is.na(.data$browse_index_id) &
.data$browse_index_id %in% c(10, 20))
.data$browse_index_id %in% c(110, 120))
),
number_of_subplots_seriously_browsed =
ifelse(
all(is.na(.data$browse_index_id)),
NA,
sum(!is.na(.data$browse_index_id) & .data$browse_index_id == 20)
sum(!is.na(.data$browse_index_id) & .data$browse_index_id == 120)
),
perc_of_subplots_browsed =
.data$number_of_subplots_browsed * 100 / .data$number_of_subplots_with_vegetation,
Expand Down
8 changes: 6 additions & 2 deletions R/calculate_vegetation_plot.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#' aggregate vegetation parameters by plot and year
#'
#' This function calculates for each plot and year the total coverage and the number of species in the vegetation layer. Year refers to year of the main vegetation survey (source is table "data_vegetation"), and will in some cases differ from the year of the spring flora survey.
#' This function calculates for each plot (subplot in case of core area) and year the total coverage and the number of species in the vegetation layer. Year refers to year of the main vegetation survey (source is table "data_vegetation"), and will in some cases differ from the year of the spring flora survey.
#'
#' @inheritParams calculate_vegetation
#'
#' @return dataframe with columns plot, year (year of main vegetation survey, possible deviating year of spring survey not taken into account) and number_of_tree_species
#' @return dataframe with columns plot, subplot, year (year of main vegetation survey, possible deviating year of spring survey not taken into account) and number_of_tree_species
#'
#' @examples
#' \dontrun{
Expand Down Expand Up @@ -53,6 +53,10 @@ calculate_vegetation_plot <- function(data_vegetation, data_herblayer) {
by = c("plot_id", "period", "subplot_id")
) %>%
mutate(
# CCC: total cover in percentage = (TL/100 + SL/100 - TL/100 * SL/100) * 100,
# where TL is the percentage cover of the tree layer and SL is the percentage cover of the shrub layer.
cumulated_canopy_cover_mean =
100 * (1 - (1 - .data$shrub_cover_mean / 100) * (1 - .data$tree_cover_mean / 100)),
leymanan marked this conversation as resolved.
Show resolved Hide resolved
cumulated_canopy_cover_min =
100 * (1 - (1 - .data$shrub_cover_min / 100) * (1 - .data$tree_cover_min / 100)),
cumulated_canopy_cover_max =
Expand Down
34 changes: 34 additions & 0 deletions R/compose_stem_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#'
#' @importFrom rlang .data
#' @importFrom dplyr %>% bind_rows filter inner_join mutate select
#' @importFrom assertthat has_name
#'
compose_stem_data <- function(data_dendro, data_shoots) {
#omit data that could be misinterpreted if data on shoot level are added
Expand All @@ -44,5 +45,38 @@ compose_stem_data <- function(data_dendro, data_shoots) {
basal_area_m2 = pi * (.data$dbh_mm / 2000) ^ 2
)

if (
has_name(
stem_data,
c("iufro_hght", "iufro_vital", "iufro_socia", "iufro_hght_shoots",
"iufro_vital_shoots", "iufro_socia_shoots",
"remark_shoots", "common_remark_shoots")
)
leymanan marked this conversation as resolved.
Show resolved Hide resolved
) {
stem_data <- stem_data %>%
mutate(
iufro_hght =
ifelse(is.na(.data$iufro_hght_shoots),
.data$iufro_hght, .data$iufro_hght_shoots),
iufro_hght_shoots = NULL,
iufro_vital =
ifelse(is.na(.data$iufro_vital_shoots),
.data$iufro_vital, .data$iufro_vital_shoots),
iufro_vital_shoots = NULL,
iufro_socia =
ifelse(is.na(.data$iufro_socia_shoots),
.data$iufro_socia, .data$iufro_socia_shoots),
iufro_socia_shoots = NULL,
remark =
ifelse(is.na(.data$remark_shoots),
.data$remark, .data$remark_shoots),
remark_shoots = NULL,
common_remark =
ifelse(is.na(.data$common_remark_shoots),
.data$common_remark, .data$common_remark_shoots),
common_remark_shoots = NULL,
)
}

return(stem_data)
}
2 changes: 1 addition & 1 deletion R/load_data_dendrometry.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ load_data_dendrometry <-
extra_variables,
", (Trees.X_m - Plots.Xorig_m) AS x_local, (Trees.Y_m - Plots.Yorig_m) AS y_local,
Trees.CoppiceID AS coppice_id, Trees.IUFROHght AS iufro_hght,
Trees.IUFROVital AS iufro_vital, IUFROSocia AS iufro_socia,
Trees.IUFROVital AS iufro_vital, Trees.IUFROSocia AS iufro_socia,
Trees.Remark AS remark, Trees.CommonRemark AS common_remark",
""
)
Expand Down
7 changes: 4 additions & 3 deletions R/load_data_regeneration.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ load_data_regeneration <-
id = c(1, 3, 8, 15, 30, 50, 80, 101, 1001),
number_class =
c("1", "2 - 5", "6 - 10", "11 - 20", "21 - 40", "41 - 60", "61 - 100", "> 100", "> 1000"),
approx_nr_regeneration = c(1, 3, 8, 15, 30, 50, 80, 101, 1001),
min_number_of_regeneration = c(1, 2, 6, 11, 21, 41, 61, 101, 1001),
max_number_of_regeneration = c(1, 5, 10, 20, 40, 60, 100, 1000, 10000),
stringsAsFactors = FALSE
Expand Down Expand Up @@ -153,9 +154,9 @@ load_data_regeneration <-
),
approx_nr_regeneration =
ifelse(
.data$min_number_of_regeneration < 100,
(.data$min_number_of_regeneration + .data$max_number_of_regeneration) / 2,
.data$min_number_of_regeneration + 1
is.na(.data$approx_nr_regeneration),
.data$nr_of_regeneration,
.data$approx_nr_regeneration
)
)

Expand Down
17 changes: 15 additions & 2 deletions R/load_data_shoots.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#' This function queries the given database to retrieve additional data on shoots to use with dendrometry data.
#'
#' @param database name of fieldmap/access database (with specific fieldmap structure) including path
#' @param extra_variables Should additional variables such as iufro_hght, iufro_vital, iufro_socia,
#' remark and common_remark be added?
#' Default is FALSE (no).
#'
#' @return Dataframe with shoot data
#'
Expand All @@ -15,15 +18,25 @@
#'
#' @export
#'
load_data_shoots <- function(database) {
load_data_shoots <- function(database, extra_variables = FALSE) {
add_fields <-
ifelse(
extra_variables,
", Shoots.IUFROHght AS iufro_hght_shoots,
Shoots.IUFROVital AS iufro_vital_shoots,
Shoots.IUFROSocia AS iufro_socia_shoots,
Shoots.Remark AS remark_shoots,
Shoots.CommonRemark AS common_remark_shoots",
""
)
query_shoots <-
"SELECT Shoots.IDPlots AS plot_id,
Shoots.IDTrees%2$s AS tree_measure_id,
Shoots.ID AS shoot_measure_id,
Shoots.DBH_mm AS dbh_mm,
Shoots.Height_m AS height_m,
Shoots.IntactSnag AS intact_snag,
Shoots.DecayStage_Shoots AS decaystage
Shoots.DecayStage_Shoots AS decaystage %4$s
FROM Shoots%2$s Shoots;"

query_shoots_1986 <-
Expand Down
13 changes: 12 additions & 1 deletion R/load_data_vegetation.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ load_data_vegetation <-
%3$s;"

query_total_cover <-
"SELECT tc.ID AS id, tc.Value1 AS cover_interval FROM qtotalCover tc"
"SELECT tc.ID AS id,
tc.Value1 AS cover_interval,
tc.Value2 AS mean_cover
leymanan marked this conversation as resolved.
Show resolved Hide resolved
FROM qtotalCover tc"

con <- odbcConnectAccess2007(database)
total_cover <- sqlQuery(con, query_total_cover, stringsAsFactors = FALSE) %>%
Expand All @@ -64,6 +67,8 @@ load_data_vegetation <-
max_cover = ifelse(.data$max_cover == "< 1%", 1, .data$max_cover),
min_cover = ifelse(.data$min_cover == "nvt", NA, .data$min_cover),
max_cover = ifelse(.data$max_cover == "nvt", NA, .data$max_cover),
mean_cover = str_replace(string = .data$mean_cover, pattern = ",", replacement = "."),
mean_cover = as.numeric(.data$mean_cover) * 100,
min_cover = as.numeric(.data$min_cover),
max_cover = as.numeric(.data$max_cover)
)
Expand Down Expand Up @@ -102,36 +107,42 @@ load_data_vegetation <-
left_join(total_cover, by = c("total_moss_cover_id" = "id")) %>%
rename(
moss_cover_interval = .data$cover_interval,
moss_cover_mean = .data$mean_cover,
moss_cover_min = .data$min_cover,
moss_cover_max = .data$max_cover
) %>%
left_join(total_cover, by = c("total_herb_cover_id" = "id")) %>%
rename(
herb_cover_interval = .data$cover_interval,
herb_cover_mean = .data$mean_cover,
herb_cover_min = .data$min_cover,
herb_cover_max = .data$max_cover
) %>%
left_join(total_cover, by = c("total_shrub_cover_id" = "id")) %>%
rename(
shrub_cover_interval = .data$cover_interval,
shrub_cover_mean = .data$mean_cover,
shrub_cover_min = .data$min_cover,
shrub_cover_max = .data$max_cover
) %>%
left_join(total_cover, by = c("total_tree_cover_id" = "id")) %>%
rename(
tree_cover_interval = .data$cover_interval,
tree_cover_mean = .data$mean_cover,
tree_cover_min = .data$min_cover,
tree_cover_max = .data$max_cover
) %>%
left_join(total_cover, by = c("total_waterlayer_cover_id" = "id")) %>%
rename(
waterlayer_cover_interval = .data$cover_interval,
waterlayer_cover_mean = .data$mean_cover,
waterlayer_cover_min = .data$min_cover,
waterlayer_cover_max = .data$max_cover
) %>%
left_join(total_cover, by = c("total_soildisturbance_game_id" = "id")) %>%
rename(
soildisturbance_game_cover_interval = .data$cover_interval,
soildisturbance_game_cover_mean = .data$mean_cover,
soildisturbance_game_cover_min = .data$min_cover,
soildisturbance_game_cover_max = .data$max_cover
) %>%
Expand Down
11 changes: 8 additions & 3 deletions R/load_plotinfo.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#' @param database name of fieldmap/access database (with specific fieldmap
#' structure) including path
#'
#' @return Dataframe with columns plot_id, plottype and forest_reserve
#' @return Dataframe with columns plot_id, plottype, forest_reserve, period, year of dendrometric survey
#' and information on (1) whether there has been a dendro, deadwood, regeneration and/or vegetation survey
#' and (2) whether the data have been processed or not.
#'
#' @examples
#' \dontrun{
Expand All @@ -30,6 +32,7 @@ load_plotinfo <- function(database) {
pd.Survey_Deadwood_YN AS survey_deadw,
pd.Survey_Vegetation_YN AS survey_veg,
pd.Survey_Regeneration_YN AS survey_reg,
pd.Date_Dendro_%1$deSet AS date_dendro,
pd.GameImpactVegObserved AS game_impact_veg,
pd.GameImpactRegObserved AS game_impact_reg,
pd.DataProcessed_YN AS data_processed
Expand Down Expand Up @@ -86,8 +89,10 @@ load_plotinfo <- function(database) {
summarise(min_period = min(.data$period)) %>%

ungroup()) %>%
mutate(survey_number = .data$period - .data$min_period + 1) %>%
select(-.data$min_period)
mutate(survey_number = .data$period - .data$min_period + 1,
year_dendro = year(round_date(.data$date_dendro, "year")) - 1
) %>%
select(-.data$min_period, -.data$date_dendro)

return(plotinfo)
}
5 changes: 3 additions & 2 deletions R/read_forresdat.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
#' @param tablename name of the table that should be read
#' @param repo_path name and path of local git repository from which data should be retrieved
#' @param join_plotinfo should table plotinfo be joined to the chosen table to
#' add columns plottype and forest_reserve? Default is TRUE. (This is only
#' add columns plottype, forest_reserve, survey_dendro/deadw/reg/veg (T or F) and data_processed (T or F)? Default is TRUE. (This is only
leymanan marked this conversation as resolved.
Show resolved Hide resolved
leymanan marked this conversation as resolved.
Show resolved Hide resolved
leymanan marked this conversation as resolved.
Show resolved Hide resolved
#' possible if the given table contains a column plot_id, so this parameter
#' should be put FALSE if this column is absent.)
#' @param plottype Data of which 'plottype' (used method) should be retrieved?
#' Default is 'CP' or 'circle plot', alternatively 'CA' or 'core area' could be
#' chosen.
#'
#' @return A dataframe with the specified table, default columns plottype and forest_reserve.
#' @return A dataframe with the specified table, default columns plottype, forest_reserve,
#' survey_dendro/deadw/reg/veg (T or F) and data_processed (T or F)
leymanan marked this conversation as resolved.
Show resolved Hide resolved
#'
#' @examples
#' \dontrun{
Expand Down
4 changes: 3 additions & 1 deletion man/calculate_vegetation_core_area_species.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/calculate_vegetation_plot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion man/load_data_shoots.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.