Repository navigation
feat: Accept a GeoZarr multiscale DataTree in from_xarray - #1359
Open
kylebarron wants to merge 7 commits into
Open
kylebarron wants to merge 7 commits into
kylebarron wants to merge 7 commits into
Conversation
kylebarron
force-pushed
the
kyle/raster-xarray-datatree
branch
from
November 16, 2026 20:43
620a1a0 to
6f319e1
Compare
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
kylebarron
force-pushed
the
kyle/raster-xarray-datatree
branch
from
November 16, 2026 21:07
6f319e1 to
3e9ab2e
Compare
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This branch has not been deployed
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.
Third of the stack toward xarray support. Stacked on the
from_xarrayPR.What I am changing
RasterLayer.from_xarrayalso accepts anxarray.DataTreeopened from a GeoZarr multiscale group withxr.open_datatree(store, engine="zarr"). Each item of the root'smultiscales.layoutnames a child group; itsvariable=(or only data variable) becomes one level, with the level's transform from the item'sspatial:transformor its coordinates, its tile size from its own chunks, and the levels sorted coarsest first by pixel size. Bounds andmin_zoomcome from the coarsest level, so a zoomed-out view of a continent-sized pyramid is a handful of small reads.Checked against carbonplan's public USGS CONUS 10 m DEM pyramid (14 levels, Zarr v3): it opens over HTTP with consolidated metadata, builds in well under a second,
min_zoomis 0, and the coarsest tile reads in about 0.2 s.The array-based layout the convention also allows (bare arrays as levels) cannot be opened by xarray when the levels share dimension names, because a
Datasetcannot hold two sizes for one dimension, so it is documented as out of scope and left to a laterfrom_zarr. The spec is updated.How I did it
build_from_xarrayis split into_single_leveland_tree_levelsbranches that each produce the level list; everything after that (tile sizes, bounds,min_zoom, loader,fetch_tile) is the single-array code over a longer list. The GeoZarr CRS finder is split intogeozarr_crs_from_attrsso it can read the tree's root attrs.How you can test it
uv run --frozen pytest tests/test_raster_xarray.py tests/test_raster.py(62 + 9 tests; the tree tests build a two-level store in memory with zarr: level order from either layout order, item transforms, levels without coordinates, thevariablerule, missingmultiscales, mismatched dims,transform=rejected,fetch_tileat each level, a dask-opened tree).PORT=18768 uv run --frozen pytest tests/ui/test_raster.py(browser: a two-level in-memory tree renders).🤖 Written by Claude Code
🤖 Generated with Claude Code