datSumCoverDom: Data - Aggregates numeric cover data to the plot or...

View source: R/datSumCoverDom.R

datSumCoverDomR Documentation

Data - Aggregates numeric cover data to the plot or condition-level.

Description

Aggregates percent cover data (e.g., COVER_PCT) to plot or condition, including options for filtering.

Usage

datSumCoverDom(
  tab = NULL,
  cond = NULL,
  plt = NULL,
  subp_cond = NULL,
  subplot = NULL,
  datsource = "obj",
  dbconn = NULL,
  dsn = NULL,
  bycond = FALSE,
  bysubp = FALSE,
  bydomainlst = NULL,
  covtype = "P2VEG",
  tsumvar = "COVER_PCT",
  tfilter = NULL,
  tdomvar = NULL,
  tdomvarlst = NULL,
  tdomvar2 = NULL,
  tdomvar2lst = NULL,
  pivot = TRUE,
  getadjplot = FALSE,
  domclassify = NULL,
  pltidsWITHqry = NULL,
  pltidsid = NULL,
  pcwhereqry = NULL,
  savedata = FALSE,
  tabIDs = tableIDs(),
  datSum_opts = datSum_options(),
  database_opts = NULL,
  savedata_opts = NULL
)

Arguments

tab

Dataframe or comma-delimited file (*.csv). The table with percent cover.

cond

Dataframe or comma-delimited file (*.csv). Condition-level table to join the aggregated tree data to, if bycond=TRUE. This table also may be used for condition proportion or strata variables used if adjcond or adjstrata = TRUE (See details below). This table is optional.

plt

Dataframe, comma-delimited file (*.csv), or shapefile (*.shp). Plot-level table to join the aggregated tree data to, if bycond=FALSE. This table is optional.

subp_cond

Dataframe, comma-delimited file (*.csv), or shapefile (*.shp). Subplot condition-level table to use to sum condition proportions, if bysubp=TRUE.

subplot

Dataframe, comma-delimited file (*.csv), or shapefile (*.shp). Subplot-level table to used to calculate adjustment factors, to remove nonsampled conditions (SUBP_STATUS_CD = 3). This table is optional. If included the aggregated tree data are joined to subplot before returning.

datsource

String. Source of data ('obj', 'csv', 'sqlite', 'gdb').

dbconn

Open database connection.

dsn

String. If datsource='sqlite', the name of SQLite database (*.sqlite).

bycond

Logical. If TRUE, the data are aggregated to the condition level (by: cuniqueid, condid). If FALSE, the data are aggregated to the plot level (by: puniqueid). If bysubp = TRUE and bycond = TRUE, data are aggregated by subplotid, subpid, condid.

bysubp

Logical. If TRUE, data are aggregated to the subplot level.

bydomainlst

String (vector). Categorical domain variables for summing tree data by (e.g., SPCD). Variables must be in tree table or plt/cond table if tables are provided.

covtype

String. Cover type for estimates (e.g. 'P2VEG')

tsumvar

String. Variable (or derivation) in tree to summarize. If covtype = 'P2VEG' and summing by plot or condition, the COVER_PCT variable in table is divided by 4 number of subplots and by 100 to convert percent to proportion ('SUM(COVER_PCT) / 4 / 100').

tfilter

String. Filter to subset the tree data before aggregating (e.g., "STATUSCD == 1"). This must be in R syntax. If tfilter=NULL, user is prompted. Use tfilter="NONE" if no filters.

tdomvar

String. The tree domain (tdom) variable used to aggregate by (e.g., "SPCD", "SPGRPCD").

tdomvarlst

String (vector). List of specific tree domains of tdomvar to aggregate (e.g., c(108, 202)). If NULL, all domains of tdomvar are used.

tdomvar2

String. A second tree domain variable to use to aggregate by (e.g. "DIACL"). The variables, tdomvar and tdomvar2 will be concatenated before summed.

tdomvar2lst

String (vector). List of specific tree domains of tdomvar2 to aggregate. If NULL, all domains of tdomvar2 are used.

pivot

Logical. If TRUE, tdomvar data are transposed (pivoted) to separate columns.

getadjplot

Logical. If TRUE, and adj='plot', adjfactors are calculated for nonsampled conditions at plot-level.

domclassify

List. List for classifying domain variables in bydomainlst (e.g., DIA = c(10,20,30)).

pltidsWITHqry

SQL query. A query identifying plots to sum (e.g., 'WITH pltids AS (SELECT cn AS PLT_CN FROM plot WHERE statecd=49 and INVYR=2018)')

pltidsid

Sting. Name of unique identifier in pltidsWITHqry.

pcwhereqry

String. Plot/Condition filter if plot and/or cond table is included.

savedata

Logical. If TRUE, saves data to outfolder.

tabIDs

List of unique IDs corresponding to the tables. See See help(tableIDs) for a list of options.

datSum_opts

List. Options for summarizing tree data, such as TPA, rounding, and adjusting TPA. See help(datSum_options()) for a list of options.

database_opts

List. Options for database, such as schema and password. See help(database_options()) for a list of options.

savedata_opts

List. See help(savedata_options()) for a list

Details

If you want to adjust plot-level or subplot-level information by condition proportions (adjplot), you need to include CONDID & CONDPROP_UNADJ in cond or tree table and COND_STATUS_CD.

Value

A list of the following items:

treedat

Data frame. Plot or condition-level table with aggregated tree attributes.

sumvars

String vector. Name(s) of the output aggregated tree attributes.

If savedata=TRUE
- treedat will be saved to the outfolder.
- a text file of input parameters is saved to outfolder ('outfn'_parameters_'date'.txt).

Note

If a dat table is provided, the aggregated tree data will be merged to table and NULL values will be output as 0.

Author(s)

Tracey S. Frescino


USDAForestService/FIESTA documentation built on July 17, 2025, 5:22 a.m.