The FIADB-API and EVALIDator web applications were designed to simplify the generation of population estimates and their associated sampling errors from data in the Forest Inventory and Analysis database (FIADB)
/fullreport
The fullreport endpoint is the primary FIA Phase 2 estimate access point for
FIADB-API.
Parameters selected in the EVALIDator interface are submitted to fullreport
which then returns the relevant estimates
NOTE! BOLDED parameters with an asterisk(*) indicate they are required. All others are optional
lat* | FOR CIRCULAR ESTIMATES ONLY * - Otherwise not required The latitude in decimal degrees for a circular estimate centroid |
lon* | FOR CIRCULAR ESTIMATES ONLY * - Otherwise not required The longitude in decimal degrees for a circular estimate centroid |
radius* | FOR CIRCULAR ESTIMATES ONLY * - Otherwise not required The radius in miles for a circular estimate |
wc* | Evaluation group code(s) for inventory(ies) of interest. Typically consists of the state FIPS code concatenated with the 4 digit inventory year. e.g. 102020 would indicate the Delaware 2020 inventory. Valid values can be found in the "EVALID" column here: https://apps.fs.usda.gov/fiadb-api/fullreport/parameters/wc |
snum* | The estimate attribute number or description of interest. Used as the numerator for ratio estimates. Users can use values either from the numeric "ATTRIBUTE_NBR", or the text "ATTRIBUTE_DESCR" found here:https://apps.fs.usda.gov/fiadb-api/fullreport/parameters/snum |
rselected* | Row estimate grouping definition, translates to rows in traditional EVALIDator table
format. Valid values can be found in the "LABEL_VAR" column here:https://apps.fs.usda.gov/fiadb-api/fullreport/parameters/rselected |
cselected* | Column estimate grouping definition, translates to columns in traditional EVALIDator
table format. Valid values can be found in the "LABEL_VAR" column here:https://apps.fs.usda.gov/fiadb-api/fullreport/parameters/cselected |
pselected | Page estimate grouping definition, translates to pages in traditional EVALIDator table
format. Valid values can be found in the "LABEL_VAR" column here:https://apps.fs.usda.gov/fiadb-api/fullreport/parameters/pselected |
rtime | Row grouping temporal basis Temporal basis for row grouping definition. Only used in area change, growth, removals, and mortality estimates as these are based on plot-revisits. Allows users to base groupings on relevant status either from the first or from the second plot visit. Valid options are: CURRENT (default) PREVIOUS CURRENT IF AVAILABLE ELSE PREVIOUS PREVIOUS IF AVAILABLE ELSE CURRENT ACCOUNTING |
ctime | Column grouping temporal basis Temporal basis for row grouping definition. Only used in area change, growth, removals, and mortality estimates as these are based on plot-revisits. Allows users to base groupings on relevant status either from the first or from the second plot visit. Valid options are: CURRENT (default) PREVIOUS CURRENT IF AVAILABLE ELSE PREVIOUS PREVIOUS IF AVAILABLE ELSE CURRENT ACCOUNTING |
ptime | Page grouping temporal basis Temporal basis for row grouping definition. Only used in area change, growth, removals, and mortality estimates as these are based on plot-revisits. Allows users to base groupings on relevant status either from the first or from the second plot visit. Valid options are: CURRENT (default) PREVIOUS CURRENT IF AVAILABLE ELSE PREVIOUS PREVIOUS IF AVAILABLE ELSE CURRENT ACCOUNTING |
sdenom | The ratio denominator estimate attribute number or description of interest. Users can use values either from the numeric "ATTRIBUTE_NBR", or the text "ATTRIBUTE_DESCR" found here:https://apps.fs.usda.gov/fiadb-api/fullreport/parameters/snum |
strFilter | SQL filter string with or without leading 'and'. E.g. "COND.OWNCD = 40" or "AND TREE.CCLCD in (1,2,3)" |
wf | SQL filter applied to non-ratio estimates - deprecated in favor of 'strFilter' but maintained for back-compatibility |
wnum | SQL filter applied to ratio estimate numerators only |
wnumdenom | SQL filter applied to ratio estimate numerators and denominators - deprecated in favor of 'strFilter' but maintained for back-compatibility |
estOnly | A value of Y returns only the grouped estimates without totals or
subtotals. Note the behavior of this parameter has changed from the previous version of the API. Error estimates are now reported for all estimates. |
FIAorRPA | Select between FIA or RPA definition of forest land. Valid options are: FIADEF* (default) RPADEF* More information on the RPA definition can be found here |
outputFormat | Desired output format for estimate returns. Valid options are: HTML* - legacy EVALIDator page/row/column cross-tabulated format - this is the default NHTML* - flat table of estimate values JSON* - legacy EVALIDator page/row/column JSON NJSON* - flat formatted JSON estimate values with metadata XML* - legacy EVALIDator page/row/column XML format NXML* - flat formatted XML estimate values with metadata |
/fullreport/parameters/<fullreport parameter name>
Adding a fullreport parameter name to the end of this endpoint will bring up a dictionary
containing valid values and context for each classed parameter used in the fullreport
endpoint
E.g. https://apps.fs.usda.gov/fiadb-api/fullreport/parameters/snum
/fullreport use examples
import requests
import pandas as pd
# this function will accept a FIADB-API fullreport URL and return dataframes for the estimates as well as subtotals, and totals where available.
def fiadb_api_GET(url):
# make request
resp = requests.get(url)
# parse response to json
data = resp.json()
# create output dictionary and populate it with estimate data frames
outDict = {}
# append estimates
outDict['estimates'] = pd.DataFrame(data['estimates'])
# append subtotals and totals if present
if 'subtotals' in data.keys():
subT = {}
for i in data['subtotals'].keys():
subT[i] = pd.DataFrame(data['subtotals'][i])
outDict['subtotals'] = subT
outDict['totals'] = pd.DataFrame(data['totals'])
# append metadata
outDict['metadata'] = data['metadata']
return outDict
# example of usage
url = "https://apps.fs.usda.gov/fiadb-api/fullreport?rselected=Land%20Use%20-%20Major&cselected=Land%20use&snum=79&wc=102020&outputFormat=NJSON"
getData = fiadb_api_GET(url=url)
# estimate data frame
getData['estimates']
# list of subtotal data frames
getData['subtotals']
# totals data frame
getData['totals']
# list all estimate metadata elements
getData['metadata'].keys()
# access metadata elements
getData['metadata']
import requests
import pandas as pd
# this function will accept a FIADB-API fullreport URL and return dataframes for the estimates as well as subtotals, and totals where available.
def fiadb_api_POST(parameterDictionary):
# make request
resp = requests.post(r"https://apps.fs.usda.gov/fiadb-api/fullreport",data=parameterDictionary)
# parse response to json
data = resp.json()
# create output dictionary and populate it with estimate data frames
outDict = {}
# append estimates
outDict['estimates'] = pd.DataFrame(data['estimates'])
# append subtotals and totals if present
if 'subtotals' in data.keys():
subT = {}
for i in data['subtotals'].keys():
subT[i] = pd.DataFrame(data['subtotals'][i])
outDict['subtotals'] = subT
outDict['totals'] = pd.DataFrame(data['totals'])
# append metadata
outDict['metadata'] = data['metadata']
return outDict
# example of usage
requestParameters = {snum:2, wc:102020, rselected:'County code and name', cselected:'Land Use - Major', outputFormat:'NJSON')
getData = fiadb_api_POST(parameterDictionary=requestParameters)
# estimate data frame
getData['estimates']
# list of subtotal data frames
getData['subtotals']
# totals data frame
getData['totals']
# list all estimate metadata elements
getData['metadata'].keys()
# access metadata elements
getData['metadata']['sql']
library(httr) #Tools for Working with URLs and HTTP
# this function will help format retrieved estimates into a more readable data frame
format_estimate = function(respList) {
return(as.data.frame(do.call(rbind, respList)))
}
# this function will accept a FIADB-API fullreport URL and return dataframes for the estimates as well as subtotals, and totals where available.
fiadb_api_GET = function(url){
# make request
resp <- httr::GET(url=url)
# parse response from JSON to R list
respObj <- httr::content(resp, "parsed", encoding = "ISO-8859-1")
# create empty output list
outputList = list()
# add estimates data frame to output list
if (! is.null(respObj$estimates)) {
outputList$estimates <- format_estimate(respObj$estimates)
} else {
print("Problem with URL or API. No estimate returned.")
return(list())
}
#Use lapply to break apart subtotal list, then call sapply to format with names
if (! is.null(respObj$subtotals))
outputList$subtotals <- sapply(lapply(respObj$subtotals, "["),
format_estimate, simplify = F, USE.NAMES = T)
# totals data frame
if (! is.null(respObj$totals))
outputList$totals <- format_estimate(respObj$totals)
# add estimate metadata, doesn't need to be reformatted
if (! is.null(respObj$metadata)) outputList$metadata <- respObj$metadata
return(outputList)
}
# example of usage
url <- "https://apps.fs.usda.gov/fiadb-api/fullreport?rselected=Land%20Use%20-%20Major&cselected=Land%20use&snum=79&wc=102020&outputFormat=NJSON"
getData <- fiadb_api_GET(url=url)
# estimate data frame
getData$estimates
# list of subtotal data frames
getData$subtotals
# totals data frame
getData$totals
# list of estimate metadata elements
getData$metadata
# access SQL used the generate estimates
getData$metadata$sql