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).
Value
Returns a data frame from resulting query.
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.
Author
Tracey S. Frescino
Examples
if (FALSE) { # \dontrun{
# 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")
} # }