Learn R Programming

rFIA (version 1.1.1)

writeFIA: Write FIA tables to local directory

Description

Write FIA.Database object to local directory as a series of .csv files representing each table. Most useful for writing merged states and temporal/spatial subsets of the database. Once written as .csv, files can be reloaded into R with readFIA().

Usage

writeFIA(db, dir, byState = FALSE, nCores = 1, ...)

Value

No return value, called to export FIA.Database object to a local directory.

Arguments

db

FIA.Database object produced from readFIA() or getFIA().

dir

directory where FIA Datatables will be stored.

nCores

numeric; number of cores to use for parallel implementation. Check available cores using detectCores. Default = 1, serial processing.

byState

logical; should tables be written out by state? Must be TRUE if planning to load data as an out-of-memory database in the future (see readFIA()).

...

other arguments to pass to data.table::fwrite().

Author

Hunter Stanke and Andrew Finley

Details

Easy, efficient parallelization is implemented with the parallel package. Users must only specify the nCores argument with a value greater than 1 in order to implement parallel processing on their machines. Parallel implementation is achieved using a snow type cluster on any Windows OS, and with multicore forking on any Unix OS (Linux, Mac). Implementing parallel processing may substantially decrease decrease free memory during processing, particularly on Windows OS. Thus, users should be cautious when running in parallel, and consider implementing serial processing for this task if computational resources are limited (nCores = 1).

See Also

readFIA, getFIA

Examples

Run this code
# \dontshow{
  # Restrict threads for CRAN compliance
  dt_threads <- data.table::getDTthreads()
  data.table::setDTthreads(1)
# }
# Write the 'fiaRI' object to a temporary directory
# Replace temp_dir with the path to your directory (where data will be saved)
temp_dir = tempdir()
writeFIA(fiaRI, dir = temp_dir)
# \dontshow{
  # Restore thread setting
  data.table::setDTthreads(dt_threads)
# }

Run the code above in your browser using DataLab