Hi rasterix 👋 - thanks for building this awesome package! I found a small bug after bringing rasterix into lazycogs. Maybe this is a known limitation and I am not using it correctly.
Using rasterix.RasterIndex via xarray.Coordinates.from_xindex(index) appears to break a chunked scalar spatial selection path in xarray.
A pattern like:
da = da.chunk(time=1).sel(x=..., y=..., method="nearest").compute()
fails when x and y come from Coordinates.from_xindex(RasterIndex(...)).
What seems to happen:
- after
sel(x=..., y=..., method="nearest"), x and y become scalar coords
- during
compute(), those lazy scalar coords materialize as shape (1,) instead of ()
- xarray then raises a shape mismatch, e.g.:
ValueError: replacement data must match the Variable's shape. replacement data has shape (1,); Variable has shape ()
Workaround on our side:
- keep the
RasterIndex attached for indexing behavior
- eagerly materialize the
x/y coordinate variables instead of using the lazy coord variables from Coordinates.from_xindex(index)
Question:
- is this a known limitation/bug in rasterix’s xarray integration?
- should scalar coord materialization after chunked selection be handled differently in
RasterIndex / create_variables() / from_xindex usage?
Hi rasterix 👋 - thanks for building this awesome package! I found a small bug after bringing rasterix into lazycogs. Maybe this is a known limitation and I am not using it correctly.
Using
rasterix.RasterIndexviaxarray.Coordinates.from_xindex(index)appears to break a chunked scalar spatial selection path in xarray.A pattern like:
fails when
xandycome fromCoordinates.from_xindex(RasterIndex(...)).What seems to happen:
sel(x=..., y=..., method="nearest"),xandybecome scalar coordscompute(), those lazy scalar coords materialize as shape(1,)instead of()Workaround on our side:
RasterIndexattached for indexing behaviorx/ycoordinate variables instead of using the lazy coord variables fromCoordinates.from_xindex(index)Question:
RasterIndex/create_variables()/from_xindexusage?