Learn R Programming

FIESTA (version 3.7.1)

DBgetCSV: Database - Extracts data table(s) from FIA DataMart.

Description

Downloads and extracts compressed comma-delimited file(s) (*.zip) from FIA DataMart (https://apps.fs.usda.gov/fia/datamart/CSV/datamart_csv.html). Only 1 table can be specified, but multiple states may be included.

Usage

DBgetCSV(
  DBtable,
  states = NULL,
  returnDT = FALSE,
  stopifnull = TRUE,
  noIDate = TRUE
)

Value

Returns a data table (returnDT=TRUE), or data.frame (returnDT=FALSE) of downloaded table(s). If more than one state, returned as one table.

Arguments

DBtable

String. Name of table to download. Only 1 table allowed.

states

String or numeric vector. Name (e.g., "Arizona", "New Mexico") or code (e.g., 4, 35) of states to download data. If NULL, tables that are not state-level are downloaded.

returnDT

Logical. If TRUE, a data table is returned, else, a data frame.

stopifnull

Logical. If TRUE, stop if table is NULL.

noIDate

Logical. If TRUE, do not include columns with type IDate.

Author

Tracey S. Frescino

Details

The compressed data files are downloaded from FIA DataMart; saved to a temporary space; extracted and imported; and deleted from temporary space. Accessibility and download time depends on access and speed of internet connection.

Examples

Run this code
if (FALSE) {
# Get plot data for multiple states
FIAplots <- DBgetCSV("PLOT", c("Georgia", "Utah"))
table(FIAplots$STATECD)
}

Run the code above in your browser using DataLab