Fix layer-mask NoDataInBounds at low zoom (MD mode)#51
Merged
scottstanie merged 1 commit intoopera-adt:mainfrom Apr 24, 2026
Merged
Conversation
`_apply_layer_masks_md` always pulled mask variables from `state.dataset` (the level-0 Dataset), but tile-rendering callers resolve the data variable from `target.dataset_for_tile_zoom(tile_z)`, which returns a *coarser* pyramid level when zoom is low. `da.where(mask_da)` then has to outer-align two grids whose y/x coordinates don't share any cell centres. The result has interleaved non-monotonic coordinates that rioxarray's `_internal_bounds` can't turn into a uniform resolution — request 500s with NoDataInBounds in the rio_tiler XarrayReader's `__attrs_post_init__`. Symptom: at high zoom (pyramid level matches level 0) the layer renders fine; zooming out so the entire raster fits in view makes the overlay disappear and floods the log with the trace above. Fix: add a `source_ds` parameter to `_apply_layer_masks_md`. The tile-rendering callsite in `XarrayPathDependency` now passes the same pyramid-level Dataset that `da` came from. Other three callers (`/point`, `/buffer_timeseries`, `/trend_analysis`) keep operating on `state.dataset` and rely on the default — they already use level 0 exclusively, so no behaviour change there. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Bug
When a layer mask is active and the user zooms out so the entire raster fits the viewport, the velocity overlay disappears and the backend logs:
At high zoom the layer renders fine — symptom only shows once the requested tile is at a low enough zoom that
dataset_for_tile_zoom(tile_z)returns a coarsened pyramid level.Root cause
_apply_layer_masks_mdlooked up mask variables instate.dataset(level 0):But the tile-rendering caller in
XarrayPathDependencyresolvesdafromtarget.dataset_for_tile_zoom(tile_z), which returns a coarser Dataset when zoomed out.da.where(mask_da)then outer-aligns two y/x grids whose cell centres don't coincide. The resulting coordinates are interleaved and non-monotonic — rioxarray's_internal_bounds()can't extract a uniform resolution from them and raises.reproject_match(used by the custom-mask path) doesn't apply here because the layer-mask path went straight throughwhere.Fix
Added
source_dskwarg to_apply_layer_masks_md. Tile-rendering callsite now passes the same pyramid-level Dataset thatdacame from. The other three callers (/point,/buffer_timeseries,/trend_analysis) all work onstate.datasetdirectly and keep relying on the default — they're at level 0 already, so no behavior change.Test plan
--stack-file cube.zarr, apply aclosure_coherence ≥ 0.5mask, zoom out until the whole raster is in view. Before this PR: overlay vanishes + 500s in log. After: overlay continues to render at every zoom.🤖 Generated with Claude Code