Repository navigation
feat: Add RasterLayer.from_xarray for a single DataArray - #1358
Open
kylebarron wants to merge 11 commits into
Open
kylebarron wants to merge 11 commits into
kylebarron wants to merge 11 commits into
Conversation
kylebarron
force-pushed
the
kyle/raster-from-xarray
branch
from
November 16, 2026 20:42
ca754c7 to
c119908
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>
Also accept float32 coordinates at their own precision, leave a region that straddles 180 unrolled, and reject (lon, lat) dim order with a hint. 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-from-xarray
branch
from
November 16, 2026 21:04
c119908 to
3bdb2ca
Compare
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.
Second of the stack toward xarray support. Stacked on #1357.
What I am changing
RasterLayer.from_xarray(da, render_tile=...)shows a 2-D(y, x)or 3-D(band, y, x)xarray.DataArrayon a regular grid as one affine level. Each tile is read from the array in Python as the browser asks for it, so the array may be in memory, dask-backed, or lazily opened from Zarr.transform=.crs=, else a list of finders tried in order: GeoZarrproj:code/proj:wkt2/proj:projjsonattrs, then a longitude/latitude name ordegrees_east/degrees_northheuristic giving EPSG:4326. Adding a metadata model later is adding one function to that list. CFgrid_mappingis a follow-up PR.tile_size=.min_zoomstops zoomed-out views from requesting every tile of a single-level array;min_zoom=overrides.load_asyncfor arrays without dask (native async on Zarr), with a permanent fallback to a thread the first time a backend raisesNotImplementedError; a thread for dask arrays. Nothing blocks the event loop.lonboard[xarray](xarray, affine); xarray, zarr and dask added to the dev group so CI runs the tests. The lock was regenerated with uv 0.13.8 and only adds packages.mkdocs.ymlso the API docs resolvexarray.DataArray.How I did it
Everything lives in
lonboard/layer/_raster_xarray.pyas small functions over alevels: list[xr.DataArray], so the next PR adds multiscale levels without changing tile fetching.from_xarrayonRasterLayeris a thin static method.affineandxarrayare imported lazily; no new core dependency.How you can test it
uv run --frozen pytest tests/test_raster_xarray.py tests/test_raster.py(48 + 9 tests: dims, transforms north-up and south-up, irregular and float32 coordinates, each CRS finder and the no-hit error, the roll and its two guards, tile sizes from dask, Zarr and no chunks,min_zoomdefault and override,fetch_tilewindows at interior and edge tiles, band dim kept, the loader's three paths).PORT=18765 uv run --frozen pytest tests/ui/test_raster.py(browser: an in-memory lon/lat array renders).uv run --frozen --group docs mkdocs build --strict.🤖 Written by Claude Code
🤖 Generated with Claude Code