fork default: LCCClassesToReplaceNNMethod = 'nearestWeighted'; require LandR (>= 1.2.0.9005) - #1
Merged
Merged
Conversation
Exposes LandR::convertUnwantedLCC()'s new `method` argument, added in PredictiveEcology/LandR#197, as a module parameter. Both options allocate each LCCClassesToReplaceNN pixel a neighbouring class drawn in proportion to that class's local abundance, and differ only in reproducibility: nearestWeighted (default) -- keyed on the pixel's ground position: deterministic, needs no seed, stable under Cache(), and a grid-aligned crop of the study area gives the same answer as the full extent (so a small dev subset agrees with the scaled-up run). nearestRandom -- draws from the RNG, for when replicates should differ. The LandR floor moves to 1.2.0.9005 for two reasons. `method` does not exist before it, so an older LandR fails with an unused-argument error rather than silently doing something else. And 1.2.0.9004 had dropped the `newPossLCC` column that the block below uses to write replacement classes back into rstLCCAdj -- the is.null() guard there silently stopped firing, leaving rstLCCAdj, and hence ecoregionMap, showing the un-replaced classes. 1.2.0.9005 restores it; the comment now records the gap. Not yet exercised end-to-end: LandWeb's renv still pins LandR 1.2.0.9004, so the lockfile needs updating once LandR#197 merges before a dataPrep run will work. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
achubaty
added a commit
to PredictiveEcology/LandWeb
that referenced
this pull request
Aug 5, 2026
…lDataPrep Bumps the Biomass_borealDataPrep submodule to FOR-CAST main, which merges the new `LCCClassesToReplaceNNMethod` parameter (FOR-CAST/Biomass_borealDataPrep#1), and sets it explicitly in both parameter configs. The fork already defaults to "nearestWeighted", so setting it here is belt-and-braces -- it keeps the intent visible next to LCCClassesToReplaceNN, and pins the behaviour if this project ever tracks upstream, whose default is "nearestRandom" (PredictiveEcology/Biomass_borealDataPrep#102). "nearestWeighted" allocates each replaced pixel a neighbouring class drawn in proportion to that class's local abundance, keyed on the pixel's ground position rather than the RNG: deterministic without a seed, stable under Cache(), and a grid-aligned crop of a study area gives the same answer as the full extent -- so a small development subset agrees with the scaled-up run. NOT yet runnable: renv still pins LandR 1.2.0.9004, which has no `method` argument. Once PredictiveEcology/LandR#197 merges, update the lockfile via `renv::install("PredictiveEcology/LandR@development", lock = TRUE)` (never snapshot()). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fork-side counterpart of PredictiveEcology#102, which adds the
LCCClassesToReplaceNNMethodparameter upstream.Depends on PredictiveEcology/LandR#197 — merge that first.
Deliberate divergence from upstream
Same parameter, different default:
"nearestRandom""nearestWeighted""nearestWeighted"keys the draw on the pixel's ground position rather than the RNG. It is deterministic, needs noset.seed(), is stable underCache(), and — because the key is the cell centre rather than the cell index — a grid-aligned crop of the study area gives the same answer as the full extent. The abundance weighting is identical to"nearestRandom"; only the source of the draw differs.Setting it as the fork default rather than in each project's parameter config means projects get the intended behaviour without having to remember to pass it.
Also here, and not upstream
The
reqdPkgsfloor moves toLandR (>= 1.2.0.9005)for a second reason that only applies to this fork: LandR 1.2.0.9004 dropped thenewPossLCCcolumn that this fork's write-back block uses.That
is.null()guard silently stopped firing under 1.2.0.9004, leavingrstLCCAdj— and thereforeecoregionMap— showing the un-replaced classes. LandR#197 restores the column; the comment now records the gap so the floor isn't lowered later without noticing. Upstream doesn't carry this block, so PredictiveEcology#102 doesn't need the note.Testing
SpaDES.core::moduleParams()registers the parameter,moduleMetadata()reports the bumped floor andversion = 1.5.13.renvstill pins LandR 1.2.0.9004, so the lockfile needs updating once LandR#197 merges before adataPreprun will exercise this.Related
Cache()/RNG interaction; affects the upstream"nearestRandom"default, not this fork's"nearestWeighted"methodargument itself🤖 Generated with Claude Code