Repository navigation
Description
Before you start
- I searched the existing issues and the roadmap and did not find a duplicate request.
What problem does this solve?
A large GeoTIFF by its address comes in one of two ways today (docs/user-guide/data-formats.md):
- Read in place: a tile layer (
map.addTileskindcog). It is drawn, but it isn't a raster.raster.process,raster.project,raster.mosaic, zonal statistics and symbology don't take it ("no raster layer"). - Whole (
"whole": true): a raster layer, but the file is downloaded whole, up toMAX_DOWNLOAD(512 MiB on the desktop, 256 MiB in the web app).
There is nothing in between: a raster of just the area one works on. Two cases:
- MapBiomas land cover. Collection 10, 2019–2024, 30 m, one COG per year for Brazil, about 1.2 GB each. It is mirrored on Source Cooperative (
https://data.source.coop/tristangruppwri/mapbiomas/mapbiomas-brazil/mapbiomas_brazil_2024/mapbiomas_brazil_2024.tif), with range requests, CORS, MODE overviews and class names in the metadata (CLASS_3=Forest Formation…). One municipality (Teresina, 1,392 km²) is about 1,400 × 3,000 pixels, some 4 million values. Today it can only be drawn (as grey, since a tile layer takes no class colours), or not had at all: the file is over the 512 MiB limit. - Copernicus GLO-30 elevation. These are 1° tiles. A plugin that puts a municipality's elevation on a UTM grid has to download each tile whole (
"whole": true, about 47 MB each) before it canraster.mosaic, clip andraster.projectit.
The reading itself exists. The data-cube commands read just an area of STAC COGs at a chosen overview, with cog::info_blocking and cog::read_values_blocking(info, url, level, band, cols, rows) (crates/tiles/src/cog.rs; used in crates/engine/src/cmd/stac.rs). It isn't offered for a single file by its address.
Proposed solution
layer.addUrl takes a "bbox" for a cloud-optimised GeoTIFF:
{"url": "https://…/mapbiomas_brazil_2024.tif", "bbox": [-42.971, -5.587, -42.599, -4.786], "name": "MapBiomas 2024"}- The header is read as for a tile layer (
cog::info). Then only the tiles that cross the box, at full resolution, come in as a raster layer of that window, in the file's coordinate system, with its no-data. The box is in longitude and latitude, and is turned into the file's system when that is another. "cellSize"(optional, in the file's units, or metres for a geographic file) picks the coarsest overview that is still finer than it. Without it, a window overMAX_VALUES_READ(256 MB) is refused with the overview that would fit, never read at a resolution nobody asked for.- Band names, and the class names a file declares (GDAL's
CLASS_<code>metadata, as in the MapBiomas files, and a band's category names when present), go to the layer. A categorical file is then ready for a Colormap or Unique Values legend (see [Feature]: Raster legend labels from class names (colour table / RAT), and editable raster class labels #889). - Without
bbox, nothing changes: a tile layer, or a whole download with"whole": true.
Choices in this proposal
- A parameter of
layer.addUrl, not a new command. It is the command that already tells a COG from other files and reads its header, and plugins and scripts already call it.bboxis the nameservice.addandstac.searchuse for the same thing. - Full resolution by default. An analysis on a 30 m product expects its pixels. The overview is only taken when the caller asks for a coarser cell, so a result never silently comes from MODE or nearest overviews (the Brazil Data Cube's overviews pick one pixel per cell).
- The same reader as the data cubes (
read_values_blocking), on the desktop and the command line. In the web app the window goes through the front end's download path, as otherlayer.addUrldownloads do (fix(plugins): a plugin's layer.addUrl downloads off the frame on the desktop #1170), reading the tiles with range requests (the server must allow CORS withRange, as for a COG read in place). - Bounded: at most
MAX_VALUES_READvalues, at most a set number of tiles, and the usual time limit. The limits go in the docs, with the overview to take for a larger area.
Estimated scope
Medium. The header, tile reads and decoding exist. What is new is turning a box into a level's columns and rows, building the raster layer from the values with its transform, carrying the class names, and the web path.
Alternatives considered
raster.projectreading the address directly, onto a grid: this is useful too, and it could follow, but it is narrower. A window as a plain raster layer serves clipping, statistics, symbology and export alike.- A STAC catalogue for each such file:
cube.reducereads by area, but needs a STAC API's search, and a static catalogue (the MapBiomas mirror has one) can't be searched ("a data cube needs a STAC API's search"). - GDAL (
gdal_translate -projwin /vsicurl/…) on the desktop works, but not in the web app, and it needs GDAL installed.
Activity
fix(raster): review of the COG window: zoom, class names kept, cell s…
fix(raster): COG window review rounds 2 and 3: pixel size, longitudes…
fix(raster): COG window says what it leaves out; band names written b…
fix(raster): COG window review rounds 6 and 7: unread keys, edge bise…
fix(raster): COG window review round 8: 0–360° files, edges to the do…
fix(raster): a window saved with fewer bands says so (opengeos#1210 r…
fix(raster): say a window's unapplied scale and offset, bound its ban…
fix(raster): say a window cut to the file, refuse any box across a fi…
fix(raster): say a window's edges left unfollowed, state its wait as …
fix(raster): say a window's unread band items, test its band cap and …
fix(raster): count a window's header read in its five minutes, share …
fix(raster): say a multi-band window's colour table left out, plain q…
fix(raster): name the address in a window's cellSize error, say point…
MapBiomas: uso e cobertura (Coleção 11) e área minerada, versão 0.1.6
feat(raster): a window of a cloud-optimised GeoTIFF by its address as…
fix(raster): a window on the frame waits for no other; windows waitin…
fix(engine): a migrated COG tile layer keeps its connection, a palett…
feat(raster): cloud-optimised GeoTIFFs are raster layers read in place (
feat(raster): read a COG window off the frame in the app (#1330, part…