Skip to main content
pyFIA downloads FIA data directly from the FIA DataMart — the Python equivalent of rFIA’s getFIA(). Data is converted to a fast DuckDB database and cached locally.

Quick start

from pyfia import download, FIA, area

db_path = download("RI")        # downloads to ~/.pyfia/data/ and caches

with FIA(db_path) as db:
    db.clip_most_recent()
    print(area(db, land_type="forest"))

Choosing what to download

db_path = download("RI")
By default pyFIA downloads the ~20 tables required by the estimation functions (common=True). Pass common=False to fetch every available table (a much larger download).

Caching

Downloads are cached, so repeated calls are instant:
db_path = download("RI")   # first call fetches from the DataMart
db_path = download("RI")   # subsequent calls return the cached path instantly
Force a fresh copy with force=True:
db_path = download("RI", force=True)

Managing the cache

from pyfia.downloader import clear_cache, cache_info

info = cache_info()
print(f"Cache size: {info['total_size_mb']:.1f} MB")
print(f"Cached states: {info['states']}")

clear_cache(older_than_days=90)            # remove stale entries
clear_cache(state="RI", delete_files=True) # clear one state

Download and open in one step

The FIA class can download and connect together:
from pyfia import FIA

db = FIA.from_download("RI")
db.clip_most_recent()
Or combine with a context manager:
from pyfia import download, FIA

with FIA(download("RI")) as db:
    db.clip_most_recent()
    # run analyses...

What gets downloaded

With common=True (the default), pyFIA fetches the tables the estimators need, including:
TableDescription
PLOTPlot-level data
TREETree measurements
CONDCondition data
SUBPLOTSubplot data
SEEDLINGSeedling data
SURVEYSurvey metadata
POP_EVAL, POP_EVAL_GRP, POP_EVAL_TYPEvaluation definitions
POP_STRATUM, POP_ESTN_UNIT, POP_PLOT_STRATUM_ASSGNStratification
TREE_GRM_COMPONENT, TREE_GRM_MIDPT, TREE_GRM_BEGINGrowth/removal/mortality
Download times and disk space vary by state size:
  • Small states (RI, DE): ~1-2 min, ~50-200 MB
  • Medium states (GA, NC): ~5-10 min, ~0.5-1 GB
  • Large states (CA, TX): ~15-30 min, 2-5 GB

Coming from rFIA

TaskrFIA (R)pyFIA (Python)
Download a stategetFIA(states = 'RI')download("RI")
Multiple statesgetFIA(states = c('GA','FL'))download(["GA", "FL"])
Common tablescommon = TRUEcommon=True
Specific tablestables = c('PLOT')tables=["PLOT"]
Save locationdir = '/path'dir="/path"

Troubleshooting

Use the lower-level client with a longer timeout and more retries:
from pyfia.downloader import DataMartClient

client = DataMartClient(timeout=600, max_retries=5)
Re-download to get a fresh copy:
download("RI", force=True)
Or clear the cached state first:
from pyfia.downloader import clear_cache
clear_cache(state="RI", delete_files=True)

Reference

See the Data Download API for the full download() signature and cache functions.