rFIA
Increase the accessibility and use of the USFS Forest Inventory and Analysis Database by providing a user-friendly, open source platform to easily query and analyze.
https://github.com/doserjef/rFIA
Category: Biosphere
Sub Category: Forest Observation and Management
Keywords
compute-estimates fia fia-database fia-datamart forest-inventory forest-variables inventories r space-time spatial
Keywords from Contributors
compute-estimates fia fia-database fia-datamart forest-inventory forest-variables inventories space-time
Last synced: about 10 hours ago
JSON representation
Repository metadata
rFIA
- Host: GitHub
- URL: https://github.com/doserjef/rFIA
- Owner: doserjef
- Created: 2019-08-05T16:33:04.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-03-07T20:08:01.000Z (about 2 months ago)
- Last Synced: 2025-04-25T10:42:23.264Z (2 days ago)
- Topics: compute-estimates, fia, fia-database, fia-datamart, forest-inventory, forest-variables, inventories, r, space-time, spatial
- Language: R
- Homepage:
- Size: 103 MB
- Stars: 51
- Watchers: 10
- Forks: 22
- Open Issues: 6
- Releases: 0
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
README.Rmd
--- output: github_document --- ```{r, include=FALSE, echo=FALSE,message=FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%") ``` # rFIA: Unlocking the FIA Database in R[](https://CRAN.R-project.org/package=rFIA) [](https://app.codecov.io/gh/doserjef/rFIA-deleted?branch=master) ## Overview The goal of `rFIA` is to increase the accessibility and use of the USFS Forest Inventory and Analysis (FIA) Database by providing a user-friendly, open source platform to easily query and analyze FIA Data. Designed to accommodate a wide range of potential user objectives, `rFIA` simplifies the estimation of forest variables from the FIA Database and allows all R users (experts and newcomers alike) to unlock the flexibility and potential inherent to the Enhanced FIA design. Specifically, `rFIA` improves accessibility to the spatio-temporal estimation capacity of the FIA Database by producing space-time indexed summaries of forest variables within user-defined population boundaries. Direct integration with other popular R packages (e.g., dplyr, sp, and sf) facilitates efficient space-time query and data summary, and supports common data representations and API design. The package implements design-based estimation procedures outlined by Bechtold & Patterson (2005), and has been validated against estimates and sampling errors produced by EVALIDator. For more information and example usage of `rFIA`, check out the numerous vignettes and example use cases in the [Articles](https://doserlab.com/files/rFIA/articles/) page on our website. To report a bug or suggest additions to `rFIA`, please use our [active issues](https://github.com/doserjef/rFIA/issues) page on GitHub, or contact [Jeff Doser](https://doserlab.com/) (maintainer). _**To cite**_ `rFIA`, please refer to the publication in [Environmental Modeling and Software](https://doi.org/10.1016/j.envsoft.2020.104664) (doi: https://doi.org/10.1016/j.envsoft.2020.104664). ## Functionality |`rFIA` Function | Description | |---------------- |----------------------------------------------------------------------| |`area()` | Estimate land area in various classes | |`areaChange()` | Estimate annual change in land area in various classes | |`biomass()` | Estimate biomass and carbon stocks of standing trees | |`carbon()` | Estimate carbon stocks by IPCC forest carbon pools | |`customPSE()` | Estimate custom variables | |`clipFIA()` | Spatial & temporal queries for FIA data | |`diversity()` | Estimate diversity indices (e.g. species diversity) | |`dwm()` | Estimate volume, biomass, and carbon stocks of down woody material | |`fsi()` | Estimate forest stability index for live tree populations | |`getDesignInfo()`| Summarize attributes of FIA's post-stratified inventories | |`getFIA()` | Download FIA data, load into R, and optionally save to disk | |`growMort()` | Estimate recruitment, mortality, and harvest rates | |`intersectFIA()` | Join attributes of a spatial polygon(s) to FIA's PLOT table | |`invasive()` | Estimate areal coverage of invasive species | |`plotFIA()` | Produce static & animated plots of FIA summaries | |`readFIA()` | Load FIA database into R environment from disk | |`seedling()` | Estimate seedling abundance (TPA) | |`standStruct()` | Estimate forest structural stage distributions | |`tpa()` | Estimate abundance of standing trees (TPA & BAA) | |`vitalRates()` | Estimate live tree growth rates | |`volume()` | Estimate merchantable volume of standing trees | |`writeFIA()` | Write in-memory FIA Database to disk | ## Installation You can install the released version of `rFIA` from [CRAN](https://CRAN.R-project.org) with: ```{r, eval = FALSE} install.packages("rFIA") ``` Currently, you can install the development version from GitHub: ```{r, eval = FALSE} devtools::install_github('doserjef/rFIA') ``` ## Example Usage ### _Download FIA Data and Load into R_ The first step to using `rFIA` is to download subsets of the FIA Database. The easiest way to accomplish this is using `getFIA()`. Using one line of code, you can download state subsets of the FIA Database, load data into your R environment, and optionally save those data to a local directory for future use! ```{r eval = FALSE} # Download the state FIA data from Connecticut (requires an internet connection) # All data acquired from FIA Datamart: https://apps.fs.usda.gov/fia/datamart/datamart.html ct <- getFIA(states = 'CT', dir = '/path/to/save/data') ``` By default, `getFIA()` only loads the portions of the database required to produce summaries with other `rFIA` functions (`common = TRUE`). This conserves memory on your machine and speeds download time. If you would like to download all available tables for a state, simple specify `common = FALSE` in the call to `getFIA()`. **But what if I want to load multiple states worth of FIA data into R?** No problem! Simply specify multiple state abbreviations in the `states` argument of `getFIA()` (e.g. `states = c('MI', 'IN', 'WI', 'IL'`)), and all state subsets will be downloaded and merged into a single `FIA.Database` object. This will allow you to use other `rFIA()` functions to produce estimates within polygons which straddle state boundaries! Note: given the massive size of the full FIA Database, users are cautioned to only download the subsets containing their region of interest. **If you have previously downloaded FIA data and would simply like to load the data into R from a local directory, use `readFIA()`:** ```{r eval = FALSE} # Load FIA Data from a local directory db <- readFIA('/path/to/your/directory/') ``` ---- ### _Compute Estimates of Forest Variables_ Now that you have loaded your FIA data into R, it's time to put it to work. Let's explore the basic functionality of `rFIA` with `tpa()`, a function to compute tree abundance estimates (trees per acre (TPA) and basal area per acre (BAA)) from FIA data, and `fiaRI`, a subset of the FIA Database for Rhode Island including inventories from 2013-2018. **Estimate the abundance of live trees in Rhode Island:** ```{r warning= FALSE, message=FALSE, fig.width = .5, fig.height=.5} library(rFIA) # Load the Rhode Island subset of the FIADB (included w/ rFIA) # NOTE: This object can be produced using getFIA and/or readFIA data("fiaRI") # Only estimates for the most recent inventory year fiaRI_MR <- clipFIA(fiaRI, mostRecent = TRUE) tpaRI_MR <- tpa(fiaRI_MR) head(tpaRI_MR) # All Inventory Years Available (i.e., returns a time series) tpaRI <- tpa(fiaRI) head(tpaRI) ``` **What if I want to group estimates by species? How about by size class?** ```{r warning= FALSE, message=FALSE, height=4.5} # Group estimates by species tpaRI_species <- tpa(fiaRI_MR, bySpecies = TRUE) head(tpaRI_species, n = 3) # Group estimates by size class # NOTE: Default 2-inch size classes, but you can make your own using makeClasses() tpaRI_sizeClass <- tpa(fiaRI_MR, bySizeClass = TRUE) head(tpaRI_sizeClass, n = 3) # Group by species and size class, and plot the distribution # for the most recent inventory year tpaRI_spsc <- tpa(fiaRI_MR, bySpecies = TRUE, bySizeClass = TRUE) plotFIA(tpaRI_spsc, BAA, grp = COMMON_NAME, x = sizeClass, plot.title = 'Size-class distributions of BAA by species', x.lab = 'Size Class (inches)', text.size = .75, n.max = 5) # Only want the top 5 species, try n.max = -5 for bottom 5 ``` **What if I want estimates for a specific type of tree (ex. greater than 12-inches DBH and in a canopy dominant or subdominant position) in a specific area (ex. growing on mesic sites), and I want to group my estimates by some variable other than species or size class (ex. ownership group)?** Easy! Each of these specifications are described in the FIA Database, and all `rFIA` functions can leverage these data to easily implement complex queries! ``` {r warning = FALSE, message = FALSE} # grpBy specifies what to group estimates by (just like species and size class above) # treeDomain describes the trees of interest, in terms of FIA variables # areaDomain, just like above, describes the land area of interest tpaRI_own <- tpa(fiaRI_MR, grpBy = OWNGRPCD, treeDomain = DIA > 12 & CCLCD %in% c(1,2), areaDomain = PHYSCLCD %in% c(20:29)) head(tpaRI_own) ``` **What if I want to produce estimates within my own population boundaries (within user-defined spatial zones/polygons)?** This is where things get really exciting. ``` {r warning = FALSE, message = FALSE} # Load the county boundaries for Rhode Island. You can load your own spatial # data using functions in sf data('countiesRI') # polys specifies the polygons (zones) where you are interested in producing estimates. # returnSpatial = TRUE indicates that the resulting estimates will be joined with the # polygons we specified, thus allowing us to visualize the estimates across space tpaRI_counties <- tpa(fiaRI_MR, polys = countiesRI, returnSpatial = TRUE) plotFIA(tpaRI_counties, BAA) # Plotting method for spatial FIA summaries, also try 'TPA' or 'TPA_PERC' ``` **We produced a really cool time series earlier, how would I marry the spatial and temporal capacity of `rFIA` to produce estimates across user-defined polygons and through time?** Easy! Just hand `tpa()` the full FIA.Database object you produced with `readFIA()` (not the most recent subset produced with `clipFIA()`). For stunning space-time visualizations, hand the output of `tpa()` to `plotFIA()`. To save the animation as a .gif file, simpy specify `fileName` (name of output file) and `savePath` (directory to save file, combined with `fileName`). ```{r warning = FALSE, message=FALSE, eval = FALSE} # Using the full FIA data set, all available inventories tpaRI_st <- tpa(fiaRI, polys = countiesRI, returnSpatial = TRUE) # Animate the output library(gganimate) plotFIA(tpaRI_st, TPA, animate = TRUE, legend.title = 'Abundance (TPA)', legend.height = .8) ```
Owner metadata
- Name: Jeff Doser
- Login: doserjef
- Email:
- Kind: user
- Description:
- Website:
- Location:
- Twitter:
- Company: Michigan State University
- Icon url: https://avatars.githubusercontent.com/u/42749980?u=d21a6f1e34bcffee44d9c2972f67d1edd5779ff1&v=4
- Repositories: 5
- Last ynced at: 2023-05-11T11:28:20.982Z
- Profile URL: https://github.com/doserjef
GitHub Events
Total
- Issues event: 13
- Watch event: 3
- Delete event: 3
- Issue comment event: 12
- Push event: 47
- Pull request event: 2
- Create event: 3
Last Year
- Issues event: 13
- Watch event: 3
- Delete event: 3
- Issue comment event: 12
- Push event: 47
- Pull request event: 2
- Create event: 3
Committers metadata
Last synced: 7 days ago
Total Commits: 425
Total Committers: 9
Avg Commits per committer: 47.222
Development Distribution Score (DDS): 0.085
Commits in past year: 25
Committers in past year: 3
Avg Commits per committer in past year: 8.333
Development Distribution Score (DDS) in past year: 0.2
Name | Commits | |
---|---|---|
Hunter | s****u@m****u | 389 |
Jeff | d****f@m****u | 20 |
Jacob Fraser | j****7@g****m | 5 |
David Diaz | d****z@v****t | 4 |
Grayson White | g****3@g****m | 2 |
Marek Petrik | m****k@c****u | 2 |
markfairbanks | m****s@g****m | 1 |
badgley | b****y | 1 |
Whalen | w****d | 1 |
Committer domains:
- msu.edu: 2
- cs.unh.edu: 1
- vibranplanet.net: 1
Issue and Pull Request metadata
Last synced: 1 day ago
Total issues: 47
Total pull requests: 12
Average time to close issues: 10 months
Average time to close pull requests: 3 months
Total issue authors: 33
Total pull request authors: 7
Average comments per issue: 2.09
Average comments per pull request: 1.25
Merged pull request: 12
Bot issues: 0
Bot pull requests: 0
Past year issues: 2
Past year pull requests: 1
Past year average time to close issues: 3 months
Past year average time to close pull requests: 7 months
Past year issue authors: 2
Past year pull request authors: 1
Past year average comments per issue: 1.5
Past year average comments per pull request: 4.0
Past year merged pull request: 1
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- hunter-stanke (4)
- jamisbruening (3)
- djj4tree (3)
- hadley (3)
- danfosterfire (2)
- lwrogers-uw (2)
- daniel-perret (2)
- eartherin (2)
- jgrn307 (2)
- malloryb (1)
- Picearubens (1)
- sofikru (1)
- scotthllrd (1)
- fab4ap (1)
- piceaSILC (1)
Top Pull Request Authors
- graysonwhite (5)
- whalend (2)
- markfairbanks (1)
- jacobf37 (1)
- d-diaz (1)
- marekpetrik (1)
- badgley (1)
Top Issue Labels
- bug (5)
- enhancement (3)
- question (1)
Top Pull Request Labels
Package metadata
- Total packages: 1
-
Total downloads:
- cran: 444 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 12
- Total maintainers: 1
cran.r-project.org: rFIA
Estimation of Forest Variables using the FIA Database
- Homepage: https://github.com/doserjef/rFIA
- Documentation: http://cran.r-project.org/web/packages/rFIA/rFIA.pdf
- Licenses: GPL-3
- Latest release: 1.1.1 (published about 2 months ago)
- Last Synced: 2025-04-26T11:01:38.897Z (1 day ago)
- Versions: 12
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 444 Last month
-
Rankings:
- Forks count: 5.032%
- Stargazers count: 7.558%
- Average: 19.461%
- Dependent packages count: 29.797%
- Dependent repos count: 35.455%
- Maintainers (1)
Dependencies
- R >= 3.1.0 depends
- bit64 * imports
- data.table * imports
- dplyr >= 1.0.0 imports
- dtplyr >= 1.0.0 imports
- ggplot2 * imports
- methods * imports
- parallel * imports
- rlang * imports
- sf * imports
- stringr * imports
- tidyr >= 1.0.0 imports
- tidyselect >= 1.0.0 imports
- R2jags * suggests
- coda * suggests
- gganimate * suggests
- knitr * suggests
- rmarkdown * suggests
Score: 12.33835012733701