{"id":28750760,"url":"https://github.com/doserjef/rfia","last_synced_at":"2025-06-16T22:02:35.716Z","repository":{"id":35505047,"uuid":"200692052","full_name":"doserjef/rFIA","owner":"doserjef","description":"rFIA","archived":false,"fork":false,"pushed_at":"2025-06-13T12:56:37.000Z","size":110715,"stargazers_count":52,"open_issues_count":8,"forks_count":22,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-06-15T11:02:39.493Z","etag":null,"topics":["compute-estimates","fia","fia-database","fia-datamart","forest-inventory","forest-variables","inventories","r","space-time","spatial"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doserjef.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-08-05T16:33:04.000Z","updated_at":"2025-06-13T12:56:41.000Z","dependencies_parsed_at":"2024-04-16T21:05:41.826Z","dependency_job_id":"a508c130-d8ff-4080-be86-b1a75d847077","html_url":"https://github.com/doserjef/rFIA","commit_stats":{"total_commits":396,"total_committers":6,"mean_commits":66.0,"dds":"0.017676767676767624","last_synced_commit":"22458bafa6ca6c10b739e96aa01ae51e1fc34157"},"previous_names":["doserjef/rfia","hunter-stanke/rfia"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/doserjef/rFIA","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doserjef%2FrFIA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doserjef%2FrFIA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doserjef%2FrFIA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doserjef%2FrFIA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doserjef","download_url":"https://codeload.github.com/doserjef/rFIA/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doserjef%2FrFIA/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260249849,"owners_count":22980760,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compute-estimates","fia","fia-database","fia-datamart","forest-inventory","forest-variables","inventories","r","space-time","spatial"],"created_at":"2025-06-16T22:01:14.680Z","updated_at":"2025-06-16T22:02:35.700Z","avatar_url":"https://github.com/doserjef.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include=FALSE, echo=FALSE,message=FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\")\n```\n# rFIA: Unlocking the FIA Database in R \u003ca href='https://doserlab.com/files/rfia/'\u003e\u003cimg src='man/figures/logo.PNG' align=\"right\" height=\"139\" width=\"180\"/\u003e\u003c/a\u003e\n\n[![CRAN](https://www.r-pkg.org/badges/version/rFIA)](https://CRAN.R-project.org/package=rFIA)\n[![Codecov test coverage](https://codecov.io/gh/doserjef/rFIA-deleted/branch/master/graph/badge.svg)](https://app.codecov.io/gh/doserjef/rFIA-deleted?branch=master)\n\n## Overview\n\nThe 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.\n\nSpecifically, `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 \u0026 Patterson (2005), and has been validated against estimates and sampling errors produced by EVALIDator. \n\nFor 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). \n\n_**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).\n\n## Functionality\n\n|`rFIA` Function  | Description                                                          |\n|---------------- |----------------------------------------------------------------------|\n|`area()`         | Estimate land area in various classes                                |\n|`areaChange()`   | Estimate annual change in land area in various classes               |\n|`biomass()`      | Estimate biomass and carbon stocks of standing trees                 |\n|`carbon()`       | Estimate carbon stocks by IPCC forest carbon pools                   |\n|`customPSE()`    | Estimate custom variables                                            |\n|`clipFIA()`      | Spatial \u0026 temporal queries for FIA data                              |\n|`diversity()`    | Estimate diversity indices (e.g. species diversity)                  |\n|`dwm()`          | Estimate volume, biomass, and carbon stocks of down woody material   |\n|`fsi()`          | Estimate forest stability index for live tree populations            |\n|`getDesignInfo()`| Summarize attributes of FIA's post-stratified inventories            |\n|`getFIA()`       | Download FIA data, load into R, and optionally save to disk          |\n|`growMort()`     | Estimate recruitment, mortality, and harvest rates                   |\n|`intersectFIA()` | Join attributes of a spatial polygon(s) to FIA's PLOT table          |\n|`invasive()`     | Estimate areal coverage of invasive species                          |\n|`plotFIA()`      | Produce static \u0026 animated plots of FIA summaries                     |\n|`readFIA()`      | Load FIA database into R environment from disk                       |\n|`seedling()`     | Estimate seedling abundance (TPA)                                    |\n|`standStruct()`  | Estimate forest structural stage distributions                       |\n|`tpa()`          | Estimate abundance of standing trees (TPA \u0026 BAA)                     |\n|`vitalRates()`   | Estimate live tree growth rates                                      |\n|`volume()`       | Estimate merchantable volume of standing trees                       |\n|`writeFIA()`     | Write in-memory FIA Database to disk                                 |\n\n## Installation\n\nYou can install the released version of `rFIA` from [CRAN](https://CRAN.R-project.org) with:\n\n```{r, eval = FALSE}\ninstall.packages(\"rFIA\")\n```\n\nCurrently, you can install the development version from GitHub:\n\n```{r, eval = FALSE}\ndevtools::install_github('doserjef/rFIA')\n```\n\n## Example Usage\n\n### _Download FIA Data and Load into R_\n\nThe 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!\n\n```{r eval = FALSE}\n# Download the state FIA data from Connecticut (requires an internet connection)\n# All data acquired from FIA Datamart: https://apps.fs.usda.gov/fia/datamart/datamart.html\nct \u003c- getFIA(states = 'CT', dir = '/path/to/save/data')\n```\n\nBy 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()`.\n\n**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!\n\nNote: given the massive size of the full FIA Database, users are cautioned to only download the subsets containing their region of interest.\n\n**If you have previously downloaded FIA data and would simply like to load the data into R from a local directory, use `readFIA()`:**\n```{r eval = FALSE}\n# Load FIA Data from a local directory\ndb \u003c- readFIA('/path/to/your/directory/')\n```\n\n----\n\n### _Compute Estimates of Forest Variables_\n\nNow 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. \n\n**Estimate the abundance of live trees in Rhode Island:**\n```{r warning= FALSE, message=FALSE, fig.width = .5, fig.height=.5}\nlibrary(rFIA)\n# Load the Rhode Island subset of the FIADB (included w/ rFIA)\n# NOTE: This object can be produced using getFIA and/or readFIA\ndata(\"fiaRI\")\n\n# Only estimates for the most recent inventory year\nfiaRI_MR \u003c- clipFIA(fiaRI, mostRecent = TRUE) \ntpaRI_MR \u003c- tpa(fiaRI_MR)\nhead(tpaRI_MR)\n\n# All Inventory Years Available (i.e., returns a time series)\ntpaRI \u003c- tpa(fiaRI)\nhead(tpaRI)\n```\n\n**What if I want to group estimates by species? How about by size class?**\n```{r warning= FALSE, message=FALSE, height=4.5}\n# Group estimates by species\ntpaRI_species \u003c- tpa(fiaRI_MR, bySpecies = TRUE)\nhead(tpaRI_species, n = 3)\n\n# Group estimates by size class\n# NOTE: Default 2-inch size classes, but you can make your own using makeClasses()\ntpaRI_sizeClass \u003c- tpa(fiaRI_MR, bySizeClass = TRUE)\nhead(tpaRI_sizeClass, n = 3)\n\n# Group by species and size class, and plot the distribution \n# for the most recent inventory year\ntpaRI_spsc \u003c- tpa(fiaRI_MR, bySpecies = TRUE, bySizeClass = TRUE)\nplotFIA(tpaRI_spsc, BAA, grp = COMMON_NAME, x = sizeClass,\n        plot.title = 'Size-class distributions of BAA by species', \n        x.lab = 'Size Class (inches)', text.size = .75,\n        n.max = 5) # Only want the top 5 species, try n.max = -5 for bottom 5\n\n```\n\n**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)?** \n\nEasy! Each of these specifications are described in the FIA Database, and all `rFIA` functions can leverage these data to easily implement complex queries!\n\n``` {r warning = FALSE, message = FALSE}\n# grpBy specifies what to group estimates by (just like species and size class above)\n# treeDomain describes the trees of interest, in terms of FIA variables \n# areaDomain, just like above, describes the land area of interest\ntpaRI_own \u003c- tpa(fiaRI_MR, \n                     grpBy = OWNGRPCD, \n                     treeDomain = DIA \u003e 12 \u0026 CCLCD %in% c(1,2),\n                     areaDomain = PHYSCLCD %in% c(20:29))\nhead(tpaRI_own)\n```\n\n**What if I want to produce estimates within my own population boundaries (within user-defined spatial zones/polygons)?** \n\nThis is where things get really exciting. \n``` {r warning = FALSE, message = FALSE}\n# Load the county boundaries for Rhode Island. You can load your own spatial \n# data using functions in sf\ndata('countiesRI')\n\n# polys specifies the polygons (zones) where you are interested in producing estimates.\n# returnSpatial = TRUE indicates that the resulting estimates will be joined with the \n# polygons we specified, thus allowing us to visualize the estimates across space\ntpaRI_counties \u003c- tpa(fiaRI_MR, polys = countiesRI, returnSpatial = TRUE)\n\nplotFIA(tpaRI_counties, BAA) # Plotting method for spatial FIA summaries, also try 'TPA' or 'TPA_PERC'\n```\n\n**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?** \n\nEasy! 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`). \n```{r warning = FALSE, message=FALSE, eval = FALSE}\n# Using the full FIA data set, all available inventories\ntpaRI_st \u003c- tpa(fiaRI, polys = countiesRI, returnSpatial = TRUE)\n\n# Animate the output\nlibrary(gganimate)\nplotFIA(tpaRI_st, TPA, animate = TRUE, legend.title = 'Abundance (TPA)', \n        legend.height = .8)\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoserjef%2Frfia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoserjef%2Frfia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoserjef%2Frfia/lists"}