Skip to content

Commit dc11538

Browse files
authored
Merge pull request #366 from natearoe/roe
fetchVegdata: add siteobsiid to vegplot tables; activate vegbasalarea table
2 parents 1c10e5a + f549a7b commit dc11538

File tree

2 files changed

+61
-59
lines changed

2 files changed

+61
-59
lines changed

R/fetchVegdata.R

+12-10
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@
88
#' get_vegplot_transpecies_from_NASIS_db
99
#' get_vegplot_tree_si_details_from_NASIS_db
1010
#' get_vegplot_tree_si_summary_from_NASIS_db get_vegplot_trhi_from_NASIS_db
11-
#'
11+
#'
1212
#' @param SS fetch data from the currently loaded selected set in NASIS or from the entire local database (default: `TRUE`)
1313
#' @param stringsAsFactors deprecated
1414
#' @param dsn Optional: path to local SQLite database containing NASIS
1515
#' table structure; default: `NULL`
1616
#'
17-
#' @return A named list containing: "vegplot", "vegplotlocation", "vegplotrhi", "vegplotspecies", "vegtransect", "vegtransplantsum", 'vegsiteindexsum', "vegsiteindexdet", and "vegplottext" tables
18-
#'
17+
#' @return A named list containing: "vegplot", "vegplotlocation", "vegplotrhi", "vegplotspecies", "vegtransect", "vegtransplantsum", 'vegsiteindexsum', "vegsiteindexdet", "vegbasalarea", and "vegplottext" tables
18+
#'
1919
#' @export
2020
#'
2121
fetchVegdata <- function(SS=TRUE, stringsAsFactors = NULL, dsn = NULL) {
22-
22+
2323
if (!missing(stringsAsFactors) && is.logical(stringsAsFactors)) {
2424
.Deprecated(msg = sprintf("stringsAsFactors argument is deprecated.\nSetting package option with `NASISDomainsAsFactor(%s)`", stringsAsFactors))
2525
NASISDomainsAsFactor(stringsAsFactors)
2626
}
27-
28-
27+
28+
2929
# check if NASIS local DB instance/ODBC data source is available
3030
.soilDB_test_NASIS_connection(dsn = dsn)
31-
31+
3232
# 1. load data in pieces
3333
site <- get_site_data_from_NASIS_db(SS = SS, dsn = dsn)
3434
vegplot <- get_vegplot_from_NASIS_db(SS = SS, dsn = dsn)
@@ -41,18 +41,19 @@ fetchVegdata <- function(SS=TRUE, stringsAsFactors = NULL, dsn = NULL) {
4141
vegprodquadrat <- get_vegplot_prodquadrats_from_NASIS_db(SS = SS, dsn = dsn)
4242
vegsiteindexsum <- get_vegplot_tree_si_summary_from_NASIS_db(SS = SS, dsn = dsn)
4343
vegsiteindexdet <- get_vegplot_tree_si_details_from_NASIS_db(SS = SS, dsn = dsn)
44+
vegbasalarea <- get_vegplot_speciesbasalarea_from_NASIS(SS = SS, dsn = dsn)
4445
vegplottext <- get_vegplot_textnote_from_NASIS_db(SS = SS, fixLineEndings = TRUE, dsn = dsn)
4546

4647

4748
# test to see if the selected set is loaded
4849
if (nrow(site) == 0 || nrow(vegplot) == 0) {
4950
message('Selected set is missing either the vegplot, pedon or site table, please load and try again :)')
5051
}
51-
52+
5253
# add ecosite id, corrdate, selection method to vegplot
5354
vegplot <- merge(site[,c("siteiid", "ecositeid", "ecositecorrdate", "siteecositehistory.classifier", "es_selection_method")],
5455
vegplot, by = "siteiid", all.x = TRUE, sort = FALSE)
55-
56+
5657
# done
5758
return(list(
5859
vegplot = vegplot,
@@ -65,8 +66,9 @@ fetchVegdata <- function(SS=TRUE, stringsAsFactors = NULL, dsn = NULL) {
6566
vegprodquadrat = vegprodquadrat,
6667
vegsiteindexsum = vegsiteindexsum,
6768
vegsiteindexdet = vegsiteindexdet,
69+
vegbasalarea = vegbasalarea,
6870
vegplottext = vegplottext,
6971
site = site
7072
))
71-
}
73+
}
7274

0 commit comments

Comments
 (0)