You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: cube.reduce masks each date by a quality band, with "median" and "first" (cloud-free composites) #2585
cube.reduce reads a STAC collection's band over an area and reduces it over time (mean, min, max…), which already works well on the Brazil Data Cube (two 16-day tiles of S2-16D-2 over Viçosa-MG at 10 m: 2664 × 2136 cells, about 1.3 s a date). But a cloud-free image needs two things it cannot do:
mask each date by its own quality band (Sentinel-2 SCL, Landsat qa_pixel, CBERS/Amazonia CMASK) before reducing;
reduce with median, or first (the first clear date in a chosen order: the "best pixel" mosaic).
Today this takes one cube.reduce per date and band (24 reads for 6 dates of B02/B03/B04/SCL), a nested if in the GeoLibre Raster Calculator per band (which binds inputs by position: #2584), and Composite Bands. It works, but it is slow to set up and depends on the optional GeoLibre tools; Cell Statistics, the only per-cell median, fails from RustGIS with two or more layers (opengeos/geolibre-rust#640), and the Raster Calculator's nodata is written as a valid value (opengeos/whitebox-wasm#62).
Proposal
New cube.reduce parameters for STAC collections:
"mask": {"asset": "SCL", "keep": [2, 4, 5, 6, 7]}, or "drop": [0, 1, 3, 8, 9, 10, 11]: a cell is used on a date only when that item's mask asset has a kept class there. A bit test "bits": {"clear": [6]} covers Landsat qa_pixel.
"stat": "median" and "stat": "first".
"order": "clear" (default for first: dates by their clear share inside the area, most first), "date" or "-date".
"assets": ["B04", "B03", "B02"]: one layer with a band for each, drawn as RGB when there are three. This would be part 2.
Choices in this proposal
The mask is read from the same item as the band (same date, same tile), so it is always aligned.
first orders dates by the clear share inside the area, not the item's eo:cloud_cover. The masks are read anyway, and a tile's cloud cover says little about a small area. Over Viçosa, LANDSAT-16D-1 of 2025-08-13 gives 29.5% and 46.5% for its two tiles, but 97% of the area has no clear observation (CLEAROB = 0).
Two PRs: part 1 adds mask, median, first and order on one asset; part 2 adds assets for a multi-band result.
Activity
fix(cube): review round 1 for several bands (opengeos#2585 part 2)
fix(cube): an averaged cell's bands are the mean of the same pixels (o…
feat(cube): cube.reduce takes several bands into one RGB layer (openg…
elpidioassinaturas commentedon Nov 27, 2026
Closing: part 1 (
mask,median,first,order) merged in #2596 and part 2 (assetsas one RGB layer) in #2712.