Skip to content

AlphaEarth embeddings as a time cube: years on the time slider (embeddings.addCube), plus similarity and change #1720

Done

Description

@elpidioassinaturas

Summary

Since #542, embeddings.search / embeddings.add open one AlphaEarth (Satellite Embedding V1, annual) tile for one year. Each year is a separate layer, and the time slider can't step through 2017–2025.

Almost everything needed for that is already in the code. A tile layer whose timeUrls lists one COG per date follows the slider. That is how stac.addCube (#559) builds a cube. I filled timeUrls by hand in a project file with the nine AlphaEarth COGs of one tile, and RustGIS 0.6.0 stepped through the years correctly (section 1b). The missing piece is a command that fills it from the AlphaEarth index.

I also tested the GeoZarr mosaic on Source Cooperative (tge-labs/aef-mosaic). It's a true (time, band, y, x) cube, but four reader limits stop it today (details below).

Proposal:

  1. embeddings.addCube: AlphaEarth tiles over an area, one tile layer per footprint, one COG per year, on the time slider. Small: it reuses stac.addCube's machinery.
  2. embeddings.similarity and embeddings.change: the analyses that make sense for embeddings. The 64 bands have no physical meaning, so the useful outputs are cosine similarity and the change between years.
  3. Optional, larger: let the Zarr reader open aef-mosaic (window reads, byte ranges inside shards, spatial:/proj: conventions, integer years as a time axis).

Tested with rustgis-cli 0.6.0 (Windows) and code read at origin/main 32ea10d (34 commits after v0.6.0).


1. What I tested

1a. The GeoZarr mosaic (https://data.source.coop/tge-labs/aef-mosaic)

The store: Zarr v3, one group, embeddings int8 (time=9, band=64, y=1,859,584, x=4,009,984), EPSG:4326 at ~0.0000898° (≈10 m at the equator). Shards are (1, 64, 4096, 4096) with inner chunks (1, 64, 256, 256), compressed with zstd and a crc32c index, and the fill value is −128. The coordinate arrays are time (int32, values 2017…2025, no units attribute), band (vlen-utf8 A00…A63), x and y (float64). The group's attributes use the draft proj:, spatial: (spatial:transform, spatial:bbox) and geoemb: conventions, including the quantization (signed_square, nodata −128). The root zarr.json has no consolidated metadata.

Command Result
raster.zarrInfo {"url": ".../aef-mosaic"} no Zarr arrays found: give a store with consolidated metadata …
raster.zarrInfo {"url": ".../aef-mosaic/embeddings"} ✅ the array is read: dims time 9, band 64, y, x, Int8, readable: true. The sharding codec is understood.
layer.addZarr {"url": ".../embeddings", "index": {"time": 7, "band": 0}} is 4009984 × 1859584, more than the 1000000000 cells a raster holds
layer.addZarr {... "time": true} has no time dimension (a coordinate with CF units, such as "days since 2001-01-01")
stac.addCube {"url": ".../aef-mosaic", ...} http status: 404 (it's not a STAC API)
stac.addCube {"url": ".../aef-mosaic/zarr.json", ...} isn't a STAC catalog or collection
layer.addUrl {"url": ".../aef-mosaic"} not a data format RustGIS reads
cube.catalog {"query": "alphaearth"} / "embedding" no entries

Why it fails, in crates/data/src/raster/zarr.rs:

  • No window. plan() (L987) always reads the whole 2-D slice and refuses anything over max_samples() (L1001). Selection (L915) only holds a variable and the indices of the other dimensions; there's no bbox.
  • Shards fetched whole. plan() returns chunk keys, and as far as I can see each one is fetched as a whole file. At Viçosa (MG, Brazil) one shard (embeddings/c/7/0/283/372) is 686 MB stored. Only one 256×256 inner chunk (~4 MiB decoded) of it would be needed. The server answers Accept-Ranges: bytes, so you could read the shard index (the last 256×16+4 bytes) and then range-read only the needed inner chunks.
  • Time axis needs CF units. time_axis() (L1379) skips a coordinate without units containing " since " (L1389). Here time holds plain integer years.
  • Georeferencing. The reader doesn't read the spatial:transform / proj:code conventions. The x coordinate (4,009,984 values, 32 MB) is longer than MAX_COORDS (L35, 4,000,000), so it isn't used either.
  • Store discovery. Without consolidated metadata, the root URL finds no arrays (L474). The member arrays embeddings, time, x and y could be probed by name from dimension_names.

1b. The per-year COGs (https://data.source.coop/tge-labs/aef/v1/annual/<year>/<zone>/<hash>-<row>-<col>.tiff)

embeddings.search {"dataset": "alphaearth", "year": Y, "bbox": [-42.89,-20.76,-42.87,-20.74]} for Y = 2017…2025 gives the same tile every year: identical bbox [-43.4264, -21.4762, -42.6283, -20.7273], UTM 23S, same -0000008192-0000000000 suffix. Only the file-name prefix changes, and it's a random hash per year (xdwdu82ch9yffuj03 in 2017, x1i7lpngfblt9wshv in 2024, …). So:

  • layer.addUrl's date template ({YYYY}) can't describe the series, because the file name isn't predictable from the year. The index has to be read.
  • The footprint (or zone + row/col suffix) is a stable key for "the same tile across years".

Proof of concept: the cube already works if timeUrls is filled. I ran embeddings.add once and saved the project. Then I edited the tile layer: I added "timeUrls": [[<ms of Jan 1 of each year>, "<that year's COG>#bands=2,17,10&range=-0.3,0.3&dequantize=aef&cube=1"], …] (nine entries) and appended &cube=1 to url. Then:

rustgis-cli run --project aef_cube.rgis \
  --cmd 'map.zoomToExtent={"extent":[-42.91,-20.78,-42.85,-20.735]}' \
  --cmd 'time.set={"dates":["2017-01-01",…,"2025-01-01"],"format":"YYYY"}' \
  --cmd 'time.goTo={"step":0}' --cmd 'share.exportMap={"path":"cube_2017.png",…}' \
  --cmd 'time.goTo={"step":4}' --cmd 'share.exportMap={"path":"cube_2021.png",…}' \
  --cmd 'time.goTo={"step":8}' --cmd 'share.exportMap={"path":"cube_2025.png",…}'

The three exports differ, each showing that year's embeddings (13 s in total, read in place). The project reopens with its nine timeUrls. I can share the project and the three exports if useful.

Two things I noticed:

  • time.info lists "tiles": [] even though a tile layer follows the slider. Maybe it only lists timeUrl templates?
  • At the last step, time.info's window reads ["2025", "2025"]. The 2025 file still drew, so this is only how the window is shown.

2. Where the gap is in the code (origin/main 32ea10d)

AlphaEarth search: crates/tiles/src/embeddings.rs

  • L225 AEF_INDEX = …/aef_index_stac_geoparquet.parquet (302,466 rows, one per tile and year).
  • L338 aef_request() reads the index in place by bbox, at most MAX_INDEX_ROWS = 4000 rows (L233). The read already returns every year in the box.
  • L275 aef_tiles() then keeps one year (L289 if y != year { return None; }), dedups by URL (L330) and keeps MAX_TILES = 60 (L235).
  • L343 / L360 search_aef / search_aef_blocking take a single year.

AlphaEarth commands: crates/engine/src/cmd/embeddings.rs

  • L96 search() → L108 emb::search_aef_blocking(area, year).
  • L127 add(): one URL. It builds the look (aef_look, cog::with_look), takes the year from the path (L144), and calls layer::add_cog (L159). There's no cube flag and no time_urls.

The cube machinery to reuse: crates/engine/src/cmd/stac.rs

  • L302 CubeFiles.tiles: BTreeMap<tile, BTreeMap<day, url>>, filled by cube_files() (L349) from a STAC API or a static collection.
  • L951 add_cube(). From L1057 (for (tile, by_day) in &tiles) it adds each tile through layer::add_url(…, "cube": true) (L1062), sets t.time_urls = urls (L1077), and turns the slider on or widens it over the dates (L1101…). It also handles the layer-room check, URL checks and undo on failure. None of this is STAC-specific.

Where the slider picks the file: crates/map/src/tiles.rs L162 time_urls, L436 apply_time() (the last date in the window), L467–471 repair() (web addresses, sorted, capped at MAX_TIME_URLS = time::MAX_STEPS = 20,000).

The look: crates/tiles/src/cog.rs L67 Look (bands, range, aef, cube), L142 with_look().

So the gap is just this: no command builds a tile → year → COG map from the AlphaEarth index and hands it to the code add_cube already has.


3. Proposal

3.1 embeddings.addCube (small)

embeddings.addCube {"dataset": "alphaearth", "bbox"?: [w,s,e,n] | "view", "start"?: 2017, "end"?: 2025,
                    "bands"?: [r,g,b], "stretch"?: 0.3, "name"?: text}
→ one tile layer per footprint, each with a COG per year, following the time slider
  1. In crates/tiles/src/embeddings.rs, add aef_cube(fields, batch, years, bbox) -> BTreeMap<String, BTreeMap<i32, Tile>>. It works like aef_tiles() without the y != year filter. Key: the EPSG code plus the -<row>-<col> stem suffix, or the footprint rounded to ~1e-6° (they match across years at Viçosa). Each year's URL is kept. Add search_aef_cube / search_aef_cube_blocking over the same aef_request(), so it's still one ranged read of the index.
    • The index holds roughly 9× the rows of a single-year search. MAX_INDEX_ROWS = 4000 should be checked against a typical view. If the read is incomplete, warn, as search() already does.
  2. In stac.rs, factor L1057–(end of slider setup) into something like pub(crate) fn add_cube_tiles(s, tiles: BTreeMap<String, BTreeMap<i64 /*ms*/, String /*url+look*/>>, base_name) -> CmdResult. add_cube() and embeddings.addCube would both call it. The AlphaEarth look would be aef_look(bands, stretch) with cube: true, through cog::with_look(), so the project reopens it as a cube (Look::cube).
  3. Dates: 1 January of each year (UTC ms), slider unit: "year", format: "YYYY".
  4. The UI: a "Years as a time cube" option in the Satellite Embeddings dialog (crates/ui-egui/src/embeddingsui.rs), next to the year picker.
  5. Attribution on every layer (CC BY 4.0): "The AlphaEarth Foundations Satellite Embedding dataset is produced by Google and Google DeepMind."

Tests: grouping by footprint across years with a hash prefix that changes per year; a missing year (a tile absent from one year's export) leaves a gap, not an error; the cube survives save and reopen (timeUrls, cube=1).

3.2 Similarity and change: what the 64 values are for

The 64 bands (A00…A63) are coordinates of a learned embedding, not reflectances or indices. An RGB of three of them is just a picture. A per-band trend, mean or range (cube.trend, cube.reduce) has no meaning for them. Google documents the embeddings as unit-length vectors on the 64-D sphere, which means:

  • Similarity between two pixels, or between a pixel and a reference, is the cosine = dot product of their 64-D vectors (after sign(v)·(v/127.5)² dequantization; renormalise to absorb quantization error).
  • Change between years at a pixel is the distance between its vector in year A and in year B: 1 − cos(v_A, v_B), or the angle acos(cos). A cube makes this a natural slider product: change relative to the first year, or year over year.

Suggested commands, both reading 64-band windows the way layer.addUrl {"bbox": …} already does (limit: 64 Mi values → ~1000×1000 px ≈ 10×10 km at 10 m):

embeddings.similarity {"dataset": "alphaearth", "year": 2024, "point": [lon, lat] | "points": layer,
                       "bbox"?: …} → Float32 raster of cosine similarity to the reference vector (or the mean of several)
embeddings.change     {"dataset": "alphaearth", "from": 2017, "to": 2025, "bbox"?: …}
                       → Float32 raster of 1 − cos(v_from, v_to)

change could also return one layer per year, as a slider series, if cube.reduce-style outputs are preferred. Nothing like this exists yet. I found no cosine or dot-product tool over raster bands, and writing a 64-term expression in the raster calculator isn't practical.

3.3 Optional: the GeoZarr mosaic

This would allow arbitrary areas without UTM tile edges, and one store for all years. It needs, in crates/data/src/raster/zarr.rs:

  1. A window on Selection (bbox → row/col ranges), with plan() listing only the chunks it touches.
  2. Byte-range reads inside sharding_indexed shards: read the index at the end, then only the inner chunks the window needs (otherwise each read fetches a whole shard of hundreds of MB).
  3. Georeferencing from spatial:transform + proj:code (zarr-conventions), with no 1-D x/y read. x here is longer than MAX_COORDS.
  4. A time axis from a coordinate of integer years (1000–9999) with no units, or from time plus the group's metadata.
  5. A root without consolidated metadata: find the arrays named in dimension_names by probing <name>/zarr.json.

With those, layer.addZarr {"url": ".../aef-mosaic", "variable": "embeddings", "index": {"band": …}, "time": true, "bbox": …} and zarr.series at a point (64 × 9 values) would work. The mosaic's README says it's "not officially supported by Google", and its conventions are still drafts, so 3.1 looks like the better first step.


Data and licence

  • Per-year COGs (Source Cooperative mirror): https://data.source.coop/tge-labs/aef/v1/annual/<year>/<zone>/…tiff. Index: …/annual/aef_index_stac_geoparquet.parquet. Google's own copy: storage.googleapis.com/alphaearth_foundations/satellite_embedding/v1/annual/… (requester-pays off).
  • Mosaic: https://source.coop/tge-labs/aef-mosaic (Zarr v3, EPSG:4326, (9, 64, 1859584, 4009984)).
  • Licence: CC BY 4.0. "The AlphaEarth Foundations Satellite Embedding dataset is produced by Google and Google DeepMind."

Activity

  1. 15 remaining items

  2. elpidioassinaturas commented on Nov 27, 2026

    @elpidioassinaturas
    ContributorAuthor

    Closing: the core list is merged — the time cube (embeddings.addCube, #1749, #2807), similarity and change (#1876, #2797), and the Zarr items 1–5 (#1885, #1951, #2117, #2227), plus range reads (#2268) and a window that follows the slider (#2298). Remaining extras (a change series over every year, a Similarity/Change section in the pane, reads across a tile edge) can get their own issues.

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