Skip to content

Add dft_rast_consensus() for temporal mode smoothing #8

Closed

Description

@NewGraphEnvironment

Problem

Single-year land cover comparisons (e.g. 2017 vs 2023) pick up noise from:

  • Misclassification in individual years (cloud shadow, spectral confusion)
  • Slight geometric shifts between satellite passes (edge pixels flip classes)
  • Seasonal timing differences (bare field vs crop depending on overpass date)

This inflates apparent change, especially at class boundaries.

Proposed Solution

Add dft_rast_consensus() — compute per-pixel mode (most frequent class) across multiple years to create a temporal consensus raster.

# Early period consensus: mode of 2017, 2018, 2019
early <- dft_rast_consensus(classified[c("2017", "2018", "2019")])

# Late period consensus: mode of 2021, 2022, 2023
late <- dft_rast_consensus(classified[c("2021", "2022", "2023")])

# Compare consensus periods — much less noise
trans <- dft_rast_transition(list(early = early, late = late),
                              from = "early", to = "late")

Scope

  • Input: named list of classified SpatRasters (same extent/resolution) — works with any categorical raster, not LULC-specific
  • Output: single SpatRaster with per-pixel mode, retaining factor levels
  • Optional: confidence layer (proportion of years agreeing on the mode, e.g. 3/3 = 1.0, 2/3 = 0.67)
  • Mean/median don't apply to categorical data — mode is the correct measure

Tradeoffs

  • Reduces false positives (misclassification noise) significantly
  • Smooths real rapid change (cleared in 2018, regrown by 2019 disappears)
  • Requires fetching more years from STAC (e.g. 6-7 instead of 2)
  • Confidence layer helps users assess reliability of detected change

Activity

  1. added a commit that references this issue on Mar 7, 2026
    8f296a1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions