Repository navigation
feat(geotiff): add a read method for arbitrary pixel windows - #792
Merged
Merged
Conversation
…verview.read
Reading a region that isn't one tile meant computing the covering tiles,
calling fetchTiles, stitching them with assembleTiles and cropping the
result by hand. async-geotiff has a `read(window=...)` method for this, and
this package mirrors its API.
Add `read({ window, pool, signal })` to GeoTIFF and Overview. It fetches
the tiles the window touches with `boundless: false` (the clipped edge
tiles that assembleTiles stitches), assembles them, and crops to the window.
A whole-image read, the default, needs no crop. The result's transform is
the image transform translated to the window's origin, and it carries a mask
when the image has a mask IFD. A window with non-integer, negative or empty
offsets or sizes, or one extending outside the image, throws a new
WindowError, as in async-geotiff. Window and WindowError are exported.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylebarron
commented
Oct 26, 2026
| export async function read( | ||
| self: CanFetchTiles, | ||
| { | ||
| window = { colOff: 0, rowOff: 0, width: self.width, height: self.height }, |
Member
Author
There was a problem hiding this comment.
TIL these default values can reference self like this
Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylebarron
added a commit
that referenced
this pull request
Nov 6, 2026
> [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. Bumps `version` to `0.10.0-beta.4` in the root `package.json` and in every `packages/*/package.json`. The publish workflow publishes it under the `beta` dist-tag, so `latest` doesn't change. `CHANGELOG.md` gets a `v0.10.0-beta.4` section with GitHub's generated notes for the 6 PRs merged since v0.10.0-beta.3. ## Breaking changes - #837: `DEFAULT_RANGE_READER` moves from `@developmentseed/deck.gl-geotiff` to `@developmentseed/deck.gl-raster`. - #838: `ZarrSource.open` takes the store and a `path` option, instead of a group you opened and `variable`. ZarrLayer's `source` takes a store too. - `open` returns a general `ZarrSource`. Narrow its data type with `source.is("float32")`. - `source.arrays` is renamed to `source.levels`. - `ZarrSource`, `ZarrLayer` and `ZarrLayerProps` lose their `Store` type argument. ## Behavior changes - #838: an array passed in inherits its parent group's `proj:` and `spatial:` attributes, unless you pass `geoZarrMetadata`. - #851: `parseGeoZarrMetadata` orders a multiscales group's levels finest first by pixel size, whatever order its `layout` lists them in. - #848: a change to `MosaicLayer`'s `updateTriggers.getSource` (or `all`) unloads every item's source and opens the sources in view again. The old items stop drawing at once. ## New APIs - #792: `read({ window, pool, signal })` on `GeoTIFF` and `Overview`, with the `Window` type and the `WindowError` class. - #838: `ZarrSource.is(dtype)` and `source.node`. ## Not included The fix for #826 (the range reader sends a read again when it arrives as the stream holding its bytes finishes) isn't written yet. 🤖 Written by [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This PR was written by Claude (Claude Code), not by @kylebarron.
Reading a region that isn't exactly one tile meant working out the covering tiles, calling
fetchTiles, stitching them withassembleTilesand cropping by hand. This addsread({ window, pool, signal })toGeoTIFFandOverview, mirroring async-geotiff'sread(window=...). It fetches the tiles the window touches, stitches them, and returns aRasterArraycovering exactly the window. Without awindow, it reads the whole image.Changes
read.ts: works out the tiles a window touches, fetches them withfetchTiles(xy, { boundless: false, pool, signal }), stitches them withassembleTiles, and crops to the window. Reading the whole image needs no crop. The result'stransformis the image transform moved to the window's origin, and it has a mask when the image has a mask IFD.Windowtype (colOff,rowOff,width,height) andWindowErrorclass inwindow.ts, both exported.readthrowsWindowErrorfor non-integer, negative or empty offsets and sizes, or a window outside the image or overview.GeoTIFF.readandOverview.readare thin wrappers, likefetchTileandfetchTiles.Tests
tests/read.test.tswith 17 tests, all failing againstmain:signal.npytiles, assembled pixel by pixel in the test.Notes
WindowandWindowErrormatch async-geotiff's names.WindowErroris the first custom error class in these packages; it lets callers tell a bad window from a failed fetch. A file that importsWindowhides the DOM's built-inWindowtype, which importing it under another name avoids.mask-1-*.npy) look out of date:Overview.readmasks match GDAL 3.12's overview masks exactly, but those files don't.Closes #405
🤖 Written by Claude Code