Serve your L1B data as ortho images and embeddings#

This guide sets up a GeoNeMo development stack that serves your own Sentinel-2 L1B granules in two ways:

  • Ortho images: surface-reflectance GeoTIFFs and JPEG previews of any window of a granule, computed on a GPU when requested. Nothing is stored.

  • Embeddings: 128-pixel chips encoded with Clay v1.5 and stored in Milvus, so you can find chips that look like a chosen one.

You prepare the granules once, and both use the same prepared inputs. The Find similar Sentinel-2 chips from L1B data shows the embedding half with a synthetic table, and On-demand ortho images from Sentinel-2 L1B describes the ortho service.

The result is surface reflectance from a fixed Sen2Cor atmosphere preset and a fixed visibility. It is not ESA’s operational L2A, and there is no cloud mask.

Contents#

  1. Check the prerequisites

  2. Get the code and build the images

  3. Arrange your L1B data

  4. Prepare the granules

  5. Make the embeddings

  6. Start the stack

  7. Load the embeddings

  8. Register the granules for ortho images

  9. Use it

  10. Stop or reset

  11. Troubleshooting

  12. Limits

1. Check the prerequisites#

Need

Detail

Linux host with an NVIDIA GPU

x86-64 or ARM64 (for example Grace). CUDA 13 driver. One GPU is enough. The ortho service reserves one GPU while the stack runs

Docker

Compose v2, BuildKit (docker buildx) and the NVIDIA Container Toolkit

Python 3.12 and uv

uv 0.12.5 is the version CI uses

git

A full clone, not shallow

Source access

A clone of the GeoNeMo repository, and read access to the cuGeo repository (CUGEO_REPOSITORY, to build the L1B image)

Internet

PyPI, npm, Docker Hub, NVIDIA NGC and Hugging Face (the Clay checkpoint, downloaded on first use)

Disk

Your corpus, plus about 15 MB per extracted granule, 26 MB per DEM cell, and about 5 GB for the model and GPU kernel cache

If you share the host with someone else’s GeoNeMo development stack, don’t run dev.sh there. It uses a fixed compose project (geonemo-services-dev), fixed ports and the geonemo-services:local image, so it would replace their stack. Use a host of your own.

2. Get the code and build the images#

Clone GeoNeMo and enter the repository.

git clone https://github.com/NVIDIA/geonemo.git geonemo
cd geonemo

Set up the workspace and prepare the server’s local skills catalog.

uv sync --locked --all-packages --extra dev --python 3.12
sh ci/prepare-public-skills.sh

Build the L1B image with build-l1b-image.sh in packs/sentinel/examples/l1b-similarity/. It holds the GPU pipeline and cuGeo’s native L1B libraries. The builder uses the latest cuGeo main from https://github.com/NVIDIA/cugeo.git. Both images use the same checkout. The build targets GPU 0’s architecture. Pass --arch 90 (for example) to choose another.

cd packs/sentinel/examples/l1b-similarity
./build-l1b-image.sh
cd -

The result is geonemo-l1b-pipeline:local. The server images are built later, by dev.sh up --build. Every image is built for the host’s own architecture, so the same commands work on x86-64 and ARM64 hosts.

3. Arrange your L1B data#

The preparation script reads one folder in a fixed layout, called a corpus here. Put everything under one data root, because every container mounts that root read-only at the same path. This guide uses these names:

Variable

Example

Holds

DATA

/data/l1b

Everything below

CORPUS

$DATA/corpus

Your L1B, L1C and auxiliary data

WORK

$DATA/work

Prepared inputs (written in section 4)

LUTS

$DATA/sen2cor/.../lib_S2B

Sen2Cor LUTs for your spacecraft

VECTORS

$DATA/vectors

The embedding table (written in section 5)

export DATA=/data/l1b
export CORPUS=$DATA/corpus
export WORK=$DATA/work
export VECTORS=$DATA/vectors

Corpus layout#

corpus/
├── worklists/
│   ├── ortho.jsonl
│   └── surface.jsonl
├── inputs/
│   ├── l1b/granules/*.tar
│   ├── l1b/datastrips/*.tar
│   └── l1c/*.SAFE/
└── auxiliary/
    ├── dem/*.tif
    ├── geoid/*.tif
    └── gipp/

Path

Contents

inputs/l1b/granules/

One tar per L1B granule (*_MSI_L1B_GR_*.tar). Each holds one granule folder with *MTD_L1B_GR*.xml, IMG_DATA/*_B02.jp2 etc. and QI_DATA/*_B02_MSIL1B.jp2 etc.

inputs/l1b/datastrips/

One tar per datastrip (*_MSI_L1B_DS_*.tar), holding *MTD_L1B_DS*.xml

inputs/l1c/

The L1C products of the same acquisition, unpacked as .SAFE folders. Each needs MTD_MSIL1C.xml and GRANULE/*/MTD_TL.xml. They give the 10 m output grid, solar irradiance and the Earth-Sun distance

auxiliary/dem/

Copernicus GLO-30 DEM tiles, named Copernicus_DSM_COG_10_N24_00_W096_00_DEM.tif. They’re in the public bucket s3://copernicus-dem-30m/. A missing tile is treated as sea level

auxiliary/geoid/

One EGM2008 geoid GeoTIFF, for example us_nga_egm08_25.tif from https://cdn.proj.org/

auxiliary/gipp/

The spacecraft’s GIPP files from your L1B source. Our reference corpus had GIP_BLINDP, GIP_SPAMOD, and GIP_VIEDIR for B01 to B12

worklists/ortho.jsonl#

This file has one JSON object per line, one per granule. Paths are relative to the corpus root.

Field

Example

product

S2B_OPER_MSI_L1B_GR_2BPS_20260922T221139_S20260922T171005_D12_N05.13: the granule folder name inside the tar

archive

inputs/l1b/granules/<product>.tar

datastrip_archive

inputs/l1b/datastrips/S2B_OPER_MSI_L1B_DS_....tar

footprint

A GeoJSON Polygon in longitude, latitude: {"type": "Polygon", "coordinates": [[[lon, lat], ...]]}

sensing_time

2026-09-22T17:10:05.968Z

detector

"12"

dataset_id

Any name for this corpus, the same on every line

worklists/surface.jsonl#

This file has one line per L1C tile.

Field

Example

input

inputs/l1c/S2B_MSIL1C_..._T14RMP_....SAFE

grid_10m

{"crs": "EPSG:32614", "ulx": 399960.0, "uly": 2900040.0, "width": 10980, "height": 10980, "xdim": 10.0, "ydim": -10.0}, from the tile’s 10 m geoposition in MTD_TL.xml

reference_l2a

The matching L2A .SAFE path if you have one. Processing doesn’t read it, but the field must be present, so any path works

tile

14RMP

dataset_id

The same name as in ortho.jsonl

Each granule is processed on the L1C tile whose 10 m grid contains its whole footprint. A granule that no single tile contains is skipped.

Sen2Cor LUTs#

Download the Sen2Cor 02.12.04 Linux installer from ESA’s Sen2Cor page and unpack it without running it:

sh Sen2Cor-02.12.04-Linux64.run --noexec \
  --target $DATA/sen2cor-02.12.04
export LUTS=$DATA/sen2cor-02.12.04/lib/python2.7/site-packages/sen2cor/lib_S2B

Use lib_S2A, lib_S2B or lib_S2C to match your spacecraft. They aren’t interchangeable.

Permissions#

The containers run as UID 10001. Make everything under DATA readable by it, and create the output folders writable:

chmod -R a+rX $DATA
mkdir -p $VECTORS $DATA/pipeline-work $DATA/cache
chmod 777 $VECTORS $DATA/pipeline-work $DATA/cache

4. Prepare the granules#

packs/sentinel/scripts/prepare_l1b_ortho.py extracts each granule and its datastrip, converts the DEM cells to the format cuGeo reads, and writes one cuGeo input per band. It also writes l1b.json, the index both the ortho service and the embedding pipeline read. It needs rasterio, which the server environment from section 2 has.

Start with a few granules:

.venv/bin/python packs/sentinel/scripts/prepare_l1b_ortho.py \
  --dataset $CORPUS --work $WORK \
  --lut-library $LUTS --limit 5

Use --granule NAME (repeatable) instead of --limit to choose granules. Rerunning adds granules to the same l1b.json; re-preparing a granule replaces its ten band inputs only when all of them succeed.

Option

Default

Meaning

--atmosphere

h99000_wv20_rura.atm

Sen2Cor preset: mid-latitude summer, rural, water vapour 2.0

--visibility-km

40

Fixed visibility, 5 to 120

--correction

terrain

terrain or flat

The script prints prepared NAME or skipped NAME: reason for each granule. Only prepared granules are in $WORK/l1b.json; $WORK/granules.json holds their public facts for the catalog (section 8).

chmod -R a+rX $WORK

5. Make the embeddings#

Run the pipeline once per prepared granule. Don’t pass the whole $WORK/granules folder: it also holds the extracted granules that were skipped, and the pipeline stops on the first one that isn’t in l1b.json. All runs append to one table.

GRANULES=$(python3 -c 'import json, sys
print(*json.load(open(sys.argv[1]))["products"])' $WORK/l1b.json)
for G in $GRANULES; do
  docker run --rm --gpus device=0 --shm-size=2g \
    --mount type=bind,src=$DATA,dst=$DATA,readonly \
    --mount type=bind,src=$VECTORS,dst=/out \
    --mount type=bind,src=$DATA/pipeline-work,dst=/work \
    --mount type=bind,src=$DATA/cache,dst=/home/pipeline/.cache \
    geonemo-l1b-pipeline:local pipeline $WORK/granules/$G \
      --l1b-manifest $WORK/l1b.json --size 128 \
      --run-mode inprocess --db-uri /out \
      --table sentinel2_l1b --limit 16
done

Option

Meaning

--limit 16

Chips per granule. Keep the total under 1024 on the development stack (section 12)

--gpus device=0

The GPU to use

$DATA mounted at $DATA

The prepared inputs name absolute host paths

Each run ends with Ingest summary and the chip count. The table is now in $VECTORS/sentinel2_l1b. The pipeline writes it readable only by UID 10001, so open it up before the next step:

docker run --rm --mount type=bind,src=$VECTORS,dst=/out \
  --entrypoint chmod geonemo-l1b-pipeline:local -R a+rX /out

Pin the table as a dataset. This fixes the exact manifest.json that the server reads, so don’t append to the table afterwards.

.venv/bin/python packs/sentinel/examples/l1b-similarity/retrieval_config.py \
  $VECTORS/sentinel2_l1b \
  --dataset-id s2-l1b \
  --producer-revision "$(git rev-parse HEAD)" \
  > $DATA/retrieval.json

It prints the chip count, the index type (FLAT under 1024 chips) and a space_id. Keep the space_id for section 7.

6. Start the stack#

One command starts the stack with both parts. It builds the server images the first time.

deploy/development/dev.sh up --build \
  --retrieval $DATA/retrieval.json \
  --retrieval-data $VECTORS \
  --l1b-ortho $WORK/l1b.json \
  --l1b-ortho-data $DATA \
  --l1b-ortho-gpu 0

Option

Meaning

--retrieval, --retrieval-data

Adds Milvus and the retrieval worker, and mounts the vectors read-only

--l1b-ortho, --l1b-ortho-data

Adds the ortho service. The index and every path it names (corpus, work, LUTs) must be inside the data folder

--l1b-ortho-gpu

The GPU index or UUID the ortho service reserves

Milvus is the upstream image from Docker Hub, pinned by its multi-arch index, so the same reference works on x86-64 and ARM64.

The stack runs without sign-in, so no credentials are needed. The ortho service checks every prepared granule’s inputs before it reports healthy, so the first start can take a few minutes. When up finishes it prints:

URL

What

http://127.0.0.1:3101

Console

http://127.0.0.1:8101/docs

API

http://127.0.0.1:8201/mcp

MCP

dev.sh remembers these options until dev.sh down, so a later plain dev.sh up keeps them.

7. Load the embeddings#

Replace SPACE_ID with the value from section 5:

deploy/development/dev.sh retrieval dataset-provision s2-l1b s2-l1b SPACE_ID
deploy/development/dev.sh retrieval dataset-import s2-l1b
deploy/development/dev.sh retrieval dataset-build s2-l1b
deploy/development/dev.sh retrieval dataset-status s2-l1b

Search works once dataset-status reports "state": "ready" with vectors equal to expected_vectors.

8. Register the granules for ortho images#

This creates one catalog record per prepared granule in the sentinel-2-l1b collection. The stack must be running.

.venv/bin/python packs/sentinel/scripts/register_l1b_granules.py \
  $WORK/granules.json --api http://127.0.0.1:8101

Each record’s ID is the granule name, for example S2B_OPER_MSI_L1B_GR_2BPS_20260922T221139_S20260922T171005_D12_N05.13.

9. Use it#

Ortho images#

R=http://127.0.0.1:8101/v1/media/records/sentinel-2-l1b/GRANULE
curl "$R/l1b-ortho/grid"
curl -o window.tif "$R/l1b-ortho?bands=B04,B03,B02&x=1000&y=1000&width=1024&height=1024"
curl -o preview.jpg "$R/l1b-ortho/preview"

Route

Returns

l1b-ortho/grid

The 10 m UTM grid (CRS, transform, size) and the ten bands

l1b-ortho?bands=&x=&y=&width=&height=&reduce=

A float32 GeoTIFF. Values are reflectance times 10000; 0 is no data

l1b-ortho/preview?bands=&max_width=&max_height=

A true-color JPEG

Windows are 16 to 4096 pixels on a side; leave them out for the whole granule. reduce (1 to 64) averages blocks for a coarser grid. A request can correct at most 128 M values (bands times pixels): all ten bands fit about 3600 x 3600 pixels. One request runs at a time and takes about 2 seconds; the first after start is slower.

Embeddings#

In the console, choose Embeddings, open s2-l1b, then Explore. Select a chip and choose Find similar to this embedding.

From a script, which also records the result in the knowledge base:

.venv/bin/python packs/sentinel/examples/l1b-similarity/find_similar_chips.py \
  --api http://127.0.0.1:8101 --corpus s2-l1b

Search results and ortho images aren’t linked in the console. To see a match, take its granule and center from the result and request that window from the ortho routes.

10. Stop or reset#

Command

Effect

deploy/development/dev.sh down

Stops the stack and keeps its data

deploy/development/dev.sh down -v

Also removes its volumes: the catalog, Milvus and the loaded dataset

To change the embeddings, make a new table (section 5), pin it, and start again with down -v: a pinned dataset can’t change.

11. Troubleshooting#

Symptom

Cause and fix

skipped NAME: no L1C tile contains the granule footprint

No tile in surface.jsonl contains the whole granule. Add the tile, or leave the granule out

skipped NAME: missing Sen2Cor LUT

--lut-library is wrong or for another spacecraft

Invalid L1B plan for NAME: 'NAME'

The pipeline was given a granule that isn’t in l1b.json. Run it per prepared granule (section 5)

Permission denied: '/work/outputs' or .../.cache/...

The pipeline’s work or cache folder isn’t writable by UID 10001

Permission denied: .../manifest.json when pinning

Run the chmod container in section 5

--l1b-ortho must name a readable L1B index or the L1B index must be inside --l1b-ortho-data

Use absolute paths, with the index under the data folder

Ortho service never healthy

Something its inputs name is outside --l1b-ortho-data or unreadable by UID 10001. Check docker logs geonemo-services-dev-l1b-ortho-1

Milvus image pull fails

Check access to Docker Hub, or set GEONEMO_MILVUS_IMAGE to a mirror of the same digest

Ortho 404 L1B granule is not served

The record’s granule isn’t in l1b.json, or the stack was started without --l1b-ortho

Ortho 413

Too many bands times pixels. Use fewer bands, a smaller window or a larger reduce

Ortho 503 with Retry-After

Four requests are already queued. Retry after 2 seconds

dataset-build fails on the development stack

1024 chips or more needs an AISAQ index on a GPU, which this Milvus doesn’t have. Use a smaller --limit

12. Limits#

  • The atmosphere is a fixed Sen2Cor preset and visibility. Nothing is retrieved per scene, there is no cloud mask, and it isn’t ESA’s operational L2A.

  • Granules that cross an L1C tile edge are skipped.

  • The development stack’s Milvus has no GPU, so it serves only FLAT indexes: fewer than 1024 chips in total.

  • The ortho service handles one request at a time on one GPU. A small window costs about as much as the whole granule.

  • The upstream Milvus image lacks the backport that reports embedded-etcd startup errors. GPU (AISAQ) index builds haven’t been qualified on ARM64.

What was tested#

On 2026-11-20, on one host, with a real Sentinel-2B corpus (one acquisition, 2026-09-22, relative orbit 69):

  • Embedding pipeline (section 5): ran on two prepared granules, 16 chips each, into one table.

  • Pinning (section 5): pinned that table: 32 chips, FLAT index.

  • Ortho service: served windows, previews and whole granules from the same prepared inputs.

  • Embeddings in the stack (sections 7 and 9): load and search were tested with a synthetic table, not real vectors.

On 2026-11-24, on one GB300 (ARM64), with three granules of the same corpus, sections 2 to 9 ran as written: preparation, the embedding pipeline (48 chips), pinning, the stack, loading, registration, ortho windows and previews, and find_similar_chips.py on the real vectors. Each ortho request took about 4 seconds. The B04 reflectance of the whole granules correlated with ESA’s L2A B04 on the same grid (r = 0.99 over land, 0.85 to 0.95 over Lake Superior, where this workflow’s water reflectance is lower than L2A’s). This is not a pixel comparison with the same run on x86-64.