Skip to content

Commit

Permalink
Add get_vegplot_speciesbasalarea_from_NASIS()
Browse files Browse the repository at this point in the history
  • Loading branch information
brownag committed Apr 20, 2023
1 parent ac55f8e commit 38b5c6f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export(get_vegplot_from_NASIS_db)
export(get_vegplot_location_from_NASIS_db)
export(get_vegplot_prodquadrats_from_NASIS_db)
export(get_vegplot_species_from_NASIS_db)
export(get_vegplot_speciesbasalarea_from_NASIS)
export(get_vegplot_textnote_from_NASIS_db)
export(get_vegplot_transect_from_NASIS_db)
export(get_vegplot_transpecies_from_NASIS_db)
Expand Down
28 changes: 28 additions & 0 deletions R/get_vegplot_data_from_NASIS_db.R
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,34 @@ get_vegplot_tree_si_summary_from_NASIS_db <- function(SS = TRUE,
return(d)
}

# get vegplot species basal area
#' @export
#' @rdname fetchVegdata
get_vegplot_speciesbasalarea_from_NASIS <- function(SS = TRUE, dsn = NULL) {
q <- "SELECT siteiid, siteobsiid, vegplotiid, vegplotid, vegplotname, obsdate,
primarydatacollector, plantiidref AS plantiid,
plotspeciebasalareaiid, basalareatreescountediid
plantsym, plantsciname, plantnatvernm,
basalareafactor, speciesnumbertreesin, speciesbasalarea,
treenumber, treeheight, treediameterbreastheight
FROM site_View_1 AS s
INNER JOIN siteobs_View_1 AS so ON so.siteiidref = s.siteiid
LEFT JOIN vegplot_View_1 AS v ON v.siteobsiidref = so.siteobsiid
LEFT JOIN plotspeciesbasalarea_View_1 AS vb ON vb.vegplotiidref = v.vegplotiid
LEFT JOIN basalareatreescounted_View_1 AS ba ON ba.plotspeciebasalareaiidref = vb.plotspeciebasalareaiid
INNER JOIN plant ON plant.plantiid = vb.plantiidref"

channel <- dbConnectNASIS(dsn)

if (inherits(channel, 'try-error'))
return(data.frame())

if (!SS) {
q <- gsub("_View_1", "", q)
}

uncode(dbQueryNASIS(channel, q), dsn = dsn)
}

# get vegplot tree site index details data
#' @export
Expand Down
3 changes: 3 additions & 0 deletions man/fetchVegdata.Rd

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

0 comments on commit 38b5c6f

Please sign in to comment.