DBqryCSV: Database - Queries FIA Online Database.

View source: R/DBqryCSV.R

DBqryCSVR Documentation

Database - Queries FIA Online Database.

Description

Downloads, extracts, and queries compressed comma-delimited file(s) (*.zip) from FIA DataMart (https://apps.fs.usda.gov/fia/datamart/CSV/datamart_csv.html). (Note: must use SQL syntax).

Usage

DBqryCSV(sql, states = NULL, sqltables = NULL)

Arguments

sql

String. A sql query. Must be appropriate sql syntax.

states

String vector. Name of state(s) in query. If not by state, set to NULL.

sqltables

String vector. Name of table(s) in sql statement to download. The sqltables must match tables in the sql statement (i.e., case-sensitive).

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 frame from resulting query.

Author(s)

Tracey S. Frescino

Examples

## Not run: 
# Number of plots by inventory year for the state of Wyoming
sql <- "select INVYR, count(*) AS NBRPLOTS
        from plot
        where statecd=56 group by INVYR"
DBqryCSV(sql = sql,
         states = "Wyoming",
         sqltables = "plot")

## End(Not run)

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