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

View source: R/DBgetCSV.R

DBgetCSVR Documentation

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
)

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.

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.

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.

Author(s)

Tracey S. Frescino

Examples

## Not run: 
# Get plot data for multiple states
FIAplots <- DBgetCSV("PLOT", c("Georgia", "Utah"))
table(FIAplots$STATECD)

## End(Not run)

FIESTA documentation built on Nov. 22, 2023, 1:07 a.m.