The FIADB-API and EVALIDator web application 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 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/fiadbstatic-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/fiadbstatic-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/fiadbstatic-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/fiadbstatic-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/fiadbstatic-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/fiadbstatic-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 deominators - deprecated in favor of 'strFilter' but maintained for back-compatibility |
estOnly | A value of Y returns only the grouped estiamtes 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 estiamtes. |
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 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/fiadbstatic-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/fiadbstatic-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)
library(jsonlite)
library(dplyr)
library(rlist)
# 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 <- GET(url=url)
# parse response from JSON to R list
respObj <- content(resp, "parsed", encoding = "ISO-8859-1")
# create empty output list
outputList = list()
# add estimates data frame to output list
outputList[['estimates']] <- as.data.frame(do.call(rbind,respObj$estimates))
# if estimate includes totals and subtotals, add those data frames to output list
if ('subtotals' %in% names(respObj)){
subtotals <- list()
# one subtotal data frame for each grouping variable
for (i in names(respObj$subtotals)){
subtotals[[i]] <- as.data.frame(do.call(rbind,respObj$subtotals[[i]]))
}
outputList[['subtotals']] <- subtotals
# totals data frame
outputList[['totals']] <- as.data.frame(do.call(rbind,respObj$totals))
}
# add estiamte metadata
outputList[['metadata']] <- respObj$metadata
return(outputList)
}
# example of usage
url <- "https://apps.fs.usda.gov/fiadbstatic-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 metadata elements
postData[['metadata']][['sql']]
library(httr)
library(jsonlite)
library(dplyr)
library(rlist)
# this function will accept a FIADB-API fullreport URL and return dataframes for
fiadb_api_POST <- function(argList){
# make request
resp <- POST(url="https://apps.fs.usda.gov/fiadbstatic-api/fullreport", body=argList, encode="form")
# parse response from JSON to R list
respObj <- content(resp, "parsed", encoding = "ISO-8859-1")
# create empty output list
outputList <- list()
# add estimates data frame to output list
outputList[['estimates']] <- as.data.frame(do.call(rbind,respObj$estimates))
# if estimate includes totals and subtotals, add those data frames to output list
if ('subtotals' %in% names(respObj)){
subtotals <- list()
# one subtotal data frame for each grouping variable
for (i in names(respObj$subtotals)){
subtotals[[i]] <- as.data.frame(do.call(rbind,respObj$subtotals[[i]]))
}
outputList[['subtotals']] <- subtotals
# totals data frame
outputList[['totals']] <- as.data.frame(do.call(rbind,respObj$totals))
}
# add estiamte metadata
outputList[['metadata']] <- respObj$metadata
return(outputList)
}
# example of usage
# create a list of parameter values
argList = list(snum=2,wc=102020,rselected='County code and name',cselected='Land Use - Major',outputFormat='NJSON')
# submit list to POST request function
postData = fiadb_api_POST(argList)
# estimate data frame
postData[['estimates']]
# list of subtotal data frames
postData[['subtotals']]
# totals data frame
postData[['totals']]
# list of estimate metadata elements
postData[['metadata']]
names(postData[['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/fiadbstatic-api/fullreport/parameters/snum
urban/fullreport
The urban fullreport endpoint is the Urban estimate generation point for FIADB-API.
geog | Urban project name(s) for which to generate estiamtes Valid options can be found in the "EVALID" column here: https://apps.fs.usda.gov/fiadbstatic-api/urban/fullreport/parameters/geog |
estnum | The urban estimate description. This is used as the numerator for ratio estimates. Valid options can be found in the "DESCRIPTION" column here: https://apps.fs.usda.gov/fiadbstatic-api/urban/fullreport/parameters/estnum |
grps | Grouping options for urban estimates Valid options can be found in the "LABEL_VAR" column here: https://apps.fs.usda.gov/fiadbstatic-api/urban/fullreport/parameters/grps |
estdenom | The urban ratio estimate denominator description. Valid options can be found in the "DESCRIPTION" column here: https://apps.fs.usda.gov/fiadbstatic-api/urban/fullreport/parameters/estnum |
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 - flat formatted JSON estimate values with metadata |
strFilter | SQL filter string with or without leading 'and'. E.g. "COND.OWNCD = 40" or "AND TREE.CCLCD in (1,2,3)" |
numFilter | SQL filter applied to ratio estimate numerators only |
cg1 | Custom Grouping SQL snippet 1. E.g. case when coalesce(cnd.owngrpcd, -1) in (10,20,30) then '`0001 Government' when coalesce(cnd.owngrpcd, -1) = 40 then '`0004 Private' else '`0006 Other' end |
cg2 | Custom Grouping SQL snippet 2. E.g. case when coalesce(cnd.owngrpcd, -1) in (10,20,30) then '`0001 Government' when coalesce(cnd.owngrpcd, -1) = 40 then '`0004 Private' else '`0006 Other' end |
/urban/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 urban fullreport endpoint
E.g. https://apps.fs.usda.gov/fiadbstatic-api/fullreport/parameters/geog