Skip to main content
Pass grp_by to any estimator to stratify the result by one or more FIA columns. When you group by common columns like forest type or ownership, pyFIA automatically adds descriptive name columns so the output is readable.

Basic grouping

from pyfia import FIA, volume, area

with FIA("RI.duckdb") as db:
    db.clip_most_recent()

    volume(db, grp_by="FORTYPCD")                 # by forest type
    area(db, grp_by="OWNGRPCD")                   # by ownership
    volume(db, grp_by=["FORTYPCD", "OWNGRPCD"])   # by both

Auto-enhanced columns

For common grouping codes, pyFIA adds a human-readable companion column automatically:
Grouping columnAuto-added columnExample values
FORTYPCDFOREST_TYPE_GROUP”Loblolly/Shortleaf Pine”, “Oak/Hickory”
OWNGRPCDOWNERSHIP_GROUP”Private”, “Forest Service”, “State and Local Government”
result = volume(db, grp_by="FORTYPCD", totals=True)
# Output includes both FORTYPCD and FOREST_TYPE_GROUP
FORTYPCDFOREST_TYPE_GROUPVOLCFNET_TOTAL
161Loblolly/Shortleaf Pine15,913,000,000
503Oak/Hickory8,592,600,000
701Oak/Gum/Cypress2,145,000,000

Species and other names

Species names require a database lookup and are not auto-enhanced. Add them after estimation with join_species_names():
from pyfia import volume, join_species_names

result = volume(db, by_species=True)
result = join_species_names(result, db)
SPCDCOMMON_NAMEVOLCFNET_TOTAL
131Loblolly pine8,234,000,000
316Red maple1,456,000,000
802White oak987,000,000
The full set of reference-table helpers:
from pyfia import (
    join_species_names,
    join_forest_type_names,
    join_state_names,
    join_multiple_references,
)

result = join_multiple_references(
    result, db, species=True, forest_type=True, state=True
)

Convenience flags

Some estimators expose flags for common groupings:
volume(db, by_species=True)        # group by species code
tpa(db, by_size_class=True)        # group by diameter size class
by_size_class is available for tpa, volume, biomass, mortality, growth, and removals, with three classification systems:
# Standard FIA ranges (default): 1.0-4.9, 5.0-9.9, 10.0-19.9, 20.0-29.9, 30.0+
mortality(db, by_size_class=True, size_class_type="standard")

# Descriptive labels: Saplings, Small, Medium, Large
mortality(db, by_size_class=True, size_class_type="descriptive")

# Timber market categories (TimberMart-South style)
removals(db, by_size_class=True, size_class_type="market")
The "market" size classes use species-aware thresholds (pine vs. hardwood) that align with timber pricing reports. Pre-merchantable trees (< 5” DBH) require tree_type="live", since growing stock starts at ≥5” DBH.

Geographic and administrative groupings

Group by columns from the PLOT table for regional analysis:
volume(db, grp_by="COUNTYCD")                    # by county
volume(db, grp_by=["STATECD", "COUNTYCD"])       # state + county
mortality(db, grp_by=["STATECD", "UNITCD"])      # state + survey unit
ColumnDescription
STATECDFIPS state code
COUNTYCDFIPS county code
UNITCDFIA survey unit code
INVYRInventory year
CYCLE / SUBCYCLEInventory cycle / subcycle

Plot-condition level estimates

Group by PLT_CN and CONDID to get one row per plot-condition — useful for linking pyFIA estimates to external plot-level models (e.g. harvest probability, growth models):
from pyfia import FIA, biomass

with FIA("RI.duckdb") as db:
    db.clip_most_recent()
    result = biomass(db, grp_by=["PLT_CN", "CONDID", "FORTYPCD"])
Each row is a single plot-condition’s contribution to the population estimate, so you can join directly on PLT_CN + CONDID without writing raw SQL.

Mortality by cause

For mortality, group by cause of death:
mortality(db, grp_by="AGENTCD")    # tree-level cause (10=Insect, 30=Fire, ...)
mortality(db, grp_by="DSTRBCD1")   # condition-level disturbance (52=Hurricane, ...)
mortality(db, grp_by=["AGENTCD", "SPCD"], variance=True)
This supports timber casualty-loss analysis, where losses must be classified by cause.

Summary

ColumnAuto-enhanced?Manual helper
FORTYPCDYesjoin_forest_type_names()
OWNGRPCDYes
SPCDNojoin_species_names()
STATECDNojoin_state_names()
COUNTYCD, UNITCD, INVYRNo
AGENTCD, DSTRBCD1No— (mortality only)

See also