From f549a7ba525f407eb0a106042ad364d245db3dbe Mon Sep 17 00:00:00 2001 From: Roe <12001003012275@FEDIDCARD.GOV> Date: Mon, 18 Nov 2024 14:24:10 -0800 Subject: [PATCH] add vegbasalarea --- R/fetchVegdata.R | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/R/fetchVegdata.R b/R/fetchVegdata.R index 8db66af5..ccaded64 100644 --- a/R/fetchVegdata.R +++ b/R/fetchVegdata.R @@ -8,27 +8,27 @@ #' get_vegplot_transpecies_from_NASIS_db #' get_vegplot_tree_si_details_from_NASIS_db #' get_vegplot_tree_si_summary_from_NASIS_db get_vegplot_trhi_from_NASIS_db -#' +#' #' @param SS fetch data from the currently loaded selected set in NASIS or from the entire local database (default: `TRUE`) #' @param stringsAsFactors deprecated #' @param dsn Optional: path to local SQLite database containing NASIS #' table structure; default: `NULL` #' -#' @return A named list containing: "vegplot", "vegplotlocation", "vegplotrhi", "vegplotspecies", "vegtransect", "vegtransplantsum", 'vegsiteindexsum', "vegsiteindexdet", and "vegplottext" tables -#' +#' @return A named list containing: "vegplot", "vegplotlocation", "vegplotrhi", "vegplotspecies", "vegtransect", "vegtransplantsum", 'vegsiteindexsum', "vegsiteindexdet", "vegbasalarea", and "vegplottext" tables +#' #' @export #' fetchVegdata <- function(SS=TRUE, stringsAsFactors = NULL, dsn = NULL) { - + if (!missing(stringsAsFactors) && is.logical(stringsAsFactors)) { .Deprecated(msg = sprintf("stringsAsFactors argument is deprecated.\nSetting package option with `NASISDomainsAsFactor(%s)`", stringsAsFactors)) NASISDomainsAsFactor(stringsAsFactors) } - - + + # check if NASIS local DB instance/ODBC data source is available .soilDB_test_NASIS_connection(dsn = dsn) - + # 1. load data in pieces site <- get_site_data_from_NASIS_db(SS = SS, dsn = dsn) vegplot <- get_vegplot_from_NASIS_db(SS = SS, dsn = dsn) @@ -41,6 +41,7 @@ fetchVegdata <- function(SS=TRUE, stringsAsFactors = NULL, dsn = NULL) { vegprodquadrat <- get_vegplot_prodquadrats_from_NASIS_db(SS = SS, dsn = dsn) vegsiteindexsum <- get_vegplot_tree_si_summary_from_NASIS_db(SS = SS, dsn = dsn) vegsiteindexdet <- get_vegplot_tree_si_details_from_NASIS_db(SS = SS, dsn = dsn) + vegbasalarea <- get_vegplot_speciesbasalarea_from_NASIS(SS = SS, dsn = dsn) vegplottext <- get_vegplot_textnote_from_NASIS_db(SS = SS, fixLineEndings = TRUE, dsn = dsn) @@ -48,11 +49,11 @@ fetchVegdata <- function(SS=TRUE, stringsAsFactors = NULL, dsn = NULL) { if (nrow(site) == 0 || nrow(vegplot) == 0) { message('Selected set is missing either the vegplot, pedon or site table, please load and try again :)') } - + # add ecosite id, corrdate, selection method to vegplot vegplot <- merge(site[,c("siteiid", "ecositeid", "ecositecorrdate", "siteecositehistory.classifier", "es_selection_method")], vegplot, by = "siteiid", all.x = TRUE, sort = FALSE) - + # done return(list( vegplot = vegplot, @@ -65,8 +66,9 @@ fetchVegdata <- function(SS=TRUE, stringsAsFactors = NULL, dsn = NULL) { vegprodquadrat = vegprodquadrat, vegsiteindexsum = vegsiteindexsum, vegsiteindexdet = vegsiteindexdet, + vegbasalarea = vegbasalarea, vegplottext = vegplottext, site = site )) -} +}