Skip to content

🌳 A Python API wrapper for the USDA Forest Service's Forest Industry and Analysis Database

Notifications You must be signed in to change notification settings

gg314/usda-fs-fiadb-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demo of results

Python USDA Forest Inventory and Analysis Database API Wrapper

This is a fairly simple wrapper to the APIs available from the US Forest Service's FIADB.

For an interactive version of trees/per acre by county, see /demo/index.html.

Documentation & Links

Usage

from fiadb import FIADB

client = FIADB()               # or:
client = FIADB(verbose = True) # print HTTP request urls for each query

fullreport Example

Valid fullReport queries can be very difficult to write and parse without testing first on the USDA's Java-based Evalidator.

# Find total number of softwood and hardwood trees by Wisconsin county
trees = client.fullreport.get(
    reptype="State",
    snum="Number of live trees (at least 1 inch d.b.h./d.r.c.), in trees, on forest land",
    wc=552018,
    pselected="None",
    rselected="County code and name",
    cselected="Species group - Major"
)["row]

See the visual examples at the bottom of this guide, which were created with data taken from fullreport queries.

evalgrp Example

# Most recent evalGrps for Minnesota, Wisconsin
client.evalgrp.get(whereClause="STATECD IN (55, 27)")
> [272018, 552018]
# All evalGrps for New York
client.evalgrp.get(whereClause="STATECD IN (26)", mostRecent="N")
> [261980, 261993, 262003, 262004, 262005, 262006, 262007, 262008, 262009, 262010, 262011, 262012, 262013, 262014, 262015, 262016, 262017, 262018, 262019]

statecdlonlatrad Example

# State codes within 100mi of Minneapolis, MN
client.statecdlonlatrad.get(lat=45, lon=93, rad=100)
> [55, 27]

reftable Example

# List all unique entries with "walnut" in the common name
walnuts = client.reftable.get(
    tableName="REF_SPECIES",
    colList="common_name, genus, species",
    whereStr="upper(common_name) LIKE '%WALNUT%'\r\n"
)
"\r\n".join(["%s | *%s %s*" % (e['COMMON_NAME'], e['GENUS'], e['SPECIES']) for e in walnuts])
Common Name Species
West Indian walnut Juglans jamaicensis
English walnut Juglans regia
Indian walnut Aleurites moluccana
walnut spp. Juglans spp.
black walnut Juglans nigra
northern California black walnut Juglans hindsii
southern California black walnut Juglans californica
Texas walnut Juglans microcarpa
Arizona walnut Juglans major

More examples

County-level choropleths (region-shaded maps) are easy to create using a utility like plotly (which has a Python implementation) or Leaflet.

> pip install plotly
> pip install psutil requests ipywidgets
# Optionally install orca for exporting static images

About

🌳 A Python API wrapper for the USDA Forest Service's Forest Industry and Analysis Database

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published