Skip to content

Stand age and disturbance-year functions move to forestInputs (re-exported, identical results) - #302

Merged
eliotmcintire merged 2 commits into
developmentfrom
forestInputs-move
Dec 4, 2026
Merged

eliotmcintire merged 2 commits into
developmentfrom
forestInputs-move

Conversation

@eliotmcintire

@eliotmcintire eliotmcintire commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

The stand age and fire-year tools now live in a small new package, forestInputs, so other projects can use them without installing all of LandR. LandR keeps the same function names, and results are identical.

Affects: the same functions and names. Stand ages for a year after 2023 change: burned stands were too young, a bug fixed in forestInputs. LandR gains forestInputs as a dependency.

Technical details

prepInputsDisturbanceYear(), disturbancesByYear(), lastDisturbanceYear(), prepInputsFireYear(), prepInputsStandAgeMap() and replaceAgeInFires() move to forestInputs (imports terra, data.table and reproducible only; LandR imports about 105 packages). R/forestInputs.R re-exports them; R/disturbanceYear.R and the moved parts of R/prepInputObjects.R are deleted, with their tests (test-disturbanceYear.R, test-prepInputsFireYear*.R, test-prepInputsStandAgeMap.R, two blocks of test-scanfiMirror.R), which now run in forestInputs. scanfiUrlRemap() and its manifest move too (LandR re-exports it); LandR's SCANFI readers switch the mirror with the same rule as forestInputs (forestInputs.scanfiMirror, else LandR.scanfiMirror), so one option covers both packages (from Alex's review). prepInputsFireYear() in forestInputs rasterizes with terra only (it used sf and fasterize).

Verified, current development (c537fb3) against this branch, separate R sessions, caching off: 8 maps on the ELF 4.3 grid (8.4 million cells) are identical cell for cell, with identical imputedPixID: disturbance years for "all" (1985, 2020), the earlier rule and NFDB only (2020); the NFDB fire year (2020); SCANFI stand age 2020 with NFDB and with "all" resets, and 1985 with NFDB. LandR tests: 234 remaining tests give the same results as before (0 failures); the 19 others are the moved tests.

Needs forestInputs >= 0.0.1.9001, which fixes replaceAgeInFires() for a startTime after 2023 (PredictiveEcology/forestInputs#3). The identity check above predates that fix and the mirror change; neither touches its maps (all at 2020 or 1985). LandR tests after the mirror change: 1499 pass, 0 fail.

Version 1.2.0.9070.

Depends-on: PredictiveEcology/forestInputs@development

🤖 Generated with Claude Code

https://claude.ai/code/session_01Lx3DXfVqAugcusGHygZGJ3

…re-exports them

prepInputsDisturbanceYear(), disturbancesByYear(), lastDisturbanceYear(),
prepInputsFireYear(), prepInputsStandAgeMap() and replaceAgeInFires() now
live in forestInputs (terra, data.table and reproducible only), so tools
that do not use LandR (e.g. hsaCEtool) share them. LandR imports and
re-exports them under the same names; their tests moved with them.

Identical results: 8 maps on the ELF 4.3 grid (disturbance years for
"all", the earlier rule and NFDB only; NFDB fire year; SCANFI stand age
with NFDB and "all" resets, 1985 and 2020) match cell for cell, with the
same imputedPixID. LandR tests: same results for every remaining test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lx3DXfVqAugcusGHygZGJ3
@eliotmcintire eliotmcintire added enhancement New feature or request backwards compatible Existing code and results keep working unchanged labels Dec 2, 2026
@achubaty

achubaty commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

I reviewed forestInputs for LandWeb, which calls prepInputsFireYear() and prepInputsStandAgeMap() through LandR:

  • Results: the move changes none of LandWeb's results. The default URLs match. prepInputsFireYear() on a SpatRaster grid with a numeric YEAR field makes the same terra::rasterize(fun = max) call as before. forestInputs passes R CMD check --as-cran with 0 errors and 0 warnings, and its 43 tests pass.
  • replaceAgeInFires() bug: it treated a startTime after 2023 as missing. So prepInputsStandAgeMap() with a dataYear after 2023 made burned stands too young, unless the area burned in dataYear itself. LandR development has the same code. replaceAgeInFires(): use a startTime after 2023 forestInputs#3 fixes it in forestInputs. Once that merges, raising this PR's floor to forestInputs (>= 0.0.1.9001) brings the fix to LandR users.
  • Duplicated mirror code: scanfiUrlRemap() now exists in both packages, with two manifests and two options (LandR.scanfiMirror, forestInputs.scanfiMirror) to keep in sync.
  • Other defects and convention points: Defects found reviewing development (1109f11) forestInputs#4 and Align with r-lib package conventions forestInputs#5.

🤖 Generated with Claude Code

LandR kept its own copy of scanfiUrlRemap() and the manifest, read only
LandR.scanfiMirror, so options(forestInputs.scanfiMirror = FALSE) switched
the mirror off for stand age but not for LandR's other SCANFI readers.
LandR now re-exports forestInputs::scanfiUrlRemap(), drops its manifest,
and switches with the same rule as forestInputs. Requires forestInputs
>= 0.0.1.9001 (replaceAgeInFires() startTime after 2023).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lx3DXfVqAugcusGHygZGJ3
@eliotmcintire
eliotmcintire merged commit 393a3d5 into development Dec 4, 2026
14 checks passed
@eliotmcintire
eliotmcintire deleted the forestInputs-move branch December 4, 2026 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards compatible Existing code and results keep working unchanged enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants