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).
DBqryCSV(sql, states = NULL, sqltables = NULL)
String. A sql query. Must be appropriate sql syntax.
String vector. Name of state(s) in query. If not by state, set to NULL.
String vector. Name of table(s) in sql statement to download. The sqltables must match tables in the sql statement (i.e., case-sensitive).
Returns a data frame from resulting query.
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.
if (FALSE) {
# 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")
}