Skip to content

[Feature]: A STAC data cube on the time slider (Brazil Data Cube as a test case) #559

Closed

Description

@elpidioassinaturas

Before you start

  • I searched the existing issues and the roadmap and did not find a duplicate request.

What problem does this solve?

Many Earth-observation data cubes are published as STAC collections of cloud-optimised GeoTIFFs: one file per tile, per date and per band. Examples are INPE's Brazil Data Cube (BDC) and Sentinel-2 on Earth Search or Planetary Computer. RustGIS already has the two halves:

I tried them together on BDC's Sentinel-2 16-day cube (S2-16D-2): a year of NDVI over Sorriso, Mato Grosso.

  • Setup: layer.addUrl with https://data.inpe.br/bdc/data/s2-16d/v2/020/019/{YYYY}/{MM}/{DD}/S2-16D_V2_020019_{YYYYMMDD}_NDVI.tif and ten dates.
  • Result: time.export wrote 10 frames in about 7 s. The crop cycle shows clearly: bare fields in August, soy in January, second-crop maize in May.
  • What else worked: stac.search against https://data.inpe.br/bdc/stac/v1 finds the items. BDC's own Albers projection, which is user-defined in each file's GeoKeys, is read correctly.

It also showed what is missing to use such a cube as a cube:

  1. One layer is one tile. BDC's tiles are about 105 km across. A view across a tile edge is blank on the far side (the top of the frames above). Sentinel-2 scenes on Earth Search overlap and change from date to date, so no single address template covers an area.
  2. The dates have to be typed. BDC's 16-day composites restart on 1 January each year, so they aren't a regular step. The dates are in the STAC items, but the slider can't take them from there.
  3. The values are raw. BDC's NDVI is int16 with scale 0.0001 and nodata -9999, which its STAC item's raster:bands states. The layer draws the stored integers in grey, with no data drawn as values.

Proposed solution

A new command, stac.addCube, adds a STAC collection's band as one raster layer that follows the time slider.

  • Command: stac.addCube {"url", "collection", "asset", "bbox"? | "view", "start", "end", "maxCloud"?, "name"?}.
    • It searches the collection over the area and period, paging, with a cap of say 2,000 items.
    • It groups the items by date: datetime, or start_datetime for composites.
    • The slider's dates are the distinct dates found. This answers point 2.
  • Drawing:
    • At each step, the layer draws that date's assets that intersect the view, each read in place as dated COGs are now: a mosaic per date. This answers point 1.
    • Where items overlap, the first valid pixel wins, in the search's order (sortby cloud cover where the API sorts).
    • Items in different projections (Sentinel-2's UTM zones) are reprojected as a single COG is today.
  • Values: the asset's raster:bands (scale, offset, nodata) are applied, so NDVI reads -1 to 1 and no data is transparent. A single band gets a colour ramp by default. This answers point 3.
  • In the app: in the STAC Search pane, Add as Time Series next to Find Items, with a band picker, when the items found span several dates.
  • Saved with the project:
    • the search: the API, collection, asset, area and period;
    • the asset addresses per date, so the project opens without searching again;
    • Refresh searches again, for a cube that has grown since.
  • Where it works:
    • On the desktop, any STAC API whose assets can be read in place.
    • On the web, only where the data server allows it (CORS). BDC's data server doesn't send CORS headers, so BDC cubes would be desktop-only.
    • Planetary Computer's signed asset addresses expire after about an hour. They would be signed again when a step is drawn.
  • Docs and tests:
    • A STAC cubes section in data.md, with the BDC example.
    • Tests against a small static STAC catalog in the test fixtures, so they need no network:
      • two tiles and three dates, irregular;
      • the dates found;
      • the mosaic at a tile edge;
      • raster:bands scale and nodata;
      • the cap;
      • a project round trip.

This would also give #555 (a time series at a point) and #556 (a summary over time) a second kind of stack beside Zarr. A point's series reads one pixel per date. A season's maximum NDVI folds the dates' mosaics over an area. I'd leave those to their own issues.

Questions before I start:

  • A layer that draws several COGs per date is a new kind of raster layer. Should it extend the dated COG layer (time_url), or be a layer of its own?
  • In the project: keep the asset addresses (no search on open), or the search alone (always current, but it needs the API)?
  • The caps: are 2,000 items, and the time slider's 20,000 dates, right?

Estimated scope

Medium: a broader feature that is feasible in a reasonable timeframe

Alternatives considered

  • A layer per tile with a typed date list: this works today, as tried above. But it needs a layer per tile, a hand-made date list, and manual scaling.
  • Mosaicking each date first (raster.mosaic) and stacking the results: this downloads and holds every tile, while the cube is meant to be read in place.
  • BDC's own services: WTSS for series and BDC Explorer for viewing. They work, but outside the map, and only for BDC.

Related

#543 (time slider), #77 (feature parity with GeoLibre: "Time Slider", "Multidimensional rasters"), #554 (Zarr on the time slider), #555 (time series at a point), #556 (summary over time).

Activity

  1. elpidioassinaturas commented on Oct 19, 2026

    @elpidioassinaturas
    ContributorAuthor

    One more requirement, which I found while making the figures for this issue: one fixed display scale across all dates and tiles.

    The COGs read in place, both the dated layer.addUrl and stac.addAsset, are tile layers. Each file is stretched in grey on its own, between the 2nd and 98th percentiles of its coarsest overview (crates/tiles/src/cog.rs). They take no colour ramp, fixed range or no-data value, because raster.symbology, raster.stretch and raster.mask need a raster layer.

    So in the animation described in the issue, a given grey is not the same NDVI in August and in January, and not the same on two tiles of one date. The seasonal change shows, but part of each frame's contrast comes from its own stretch. For a cube that is the wrong default: the point of stepping through dates is to compare them.

    What the cube layer should do:

    • Fixed range: one stretch for the whole layer, the same for every date and every tile.
      • It comes from a range the user gives (NDVI 0 to 0.9, say), applied after raster:bands scale/offset.
      • Without one, it comes from the asset's statistics where the STAC item has them.
      • Failing that, it is computed once from a sample of dates, not per file and frame.
    • Colour ramp and no data: the same ramp for every date, and raster:bands nodata drawn transparent.
    • Legend: one legend for the layer, valid at every step.

    For comparison, the panel below shows what that looks like:

    • Data: BDC's S2-16D-2 NDVI over Sorriso (MT), tiles 020018 and 020019, on 12 Aug 2024, 1 Jan 2025 and 9 May 2025.
    • Display: a brown-to-green ramp fixed at 0 to 0.9 for all three dates.
    • How I made it: with rustgis-cli on main (a47ce62), by first clipping the view's window out of the COGs with GDAL into local GeoTIFFs. As raster layers they accept ramp.add, raster.symbology, raster.stretch (custom 0–9000) and raster.mask (-9999).
    • What it shows: the two tiles meet without a seam, and the season reads directly from the colours:
      • dry-season stubble in August;
      • soy in January, where the brown spots are clouds left in the 16-day composite;
      • second-crop maize in May.

    The cube layer should give this without the download step.

    🤖 Generated with Claude Code

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions