Skip to content

Fix polygon_clip: pass dask chunks to rasterize for lazy mask (#1207)#1209

Merged
brendancol merged 1 commit intomasterfrom
issue-1207
Apr 16, 2026
Merged

Fix polygon_clip: pass dask chunks to rasterize for lazy mask (#1207)#1209
brendancol merged 1 commit intomasterfrom
issue-1207

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

Fixes #1207. clip_polygon() called rasterize() without passing chunks, so the polygon mask was always built as a full numpy array even for dask-backed inputs. For large rasters this materializes the entire mask in RAM, defeating chunked evaluation.

Now extracts chunk sizes from the input raster and passes them to rasterize() so it uses its _run_dask_numpy path. Also sets use_cuda=True for dask+cupy inputs.

Two-line fix in the call site, no changes to rasterize itself.

Test plan

  • All 22 existing polygon_clip tests pass (numpy, dask, cupy, dask+cupy, geodataframe)
  • New test: verifies the dask task graph has chunk-level tasks (mask built lazily, not wrapped after the fact)

clip_polygon() was calling rasterize() without chunks=, so the polygon
mask was always built as a full numpy array even for dask-backed inputs.
For large rasters this defeats chunked evaluation and OOMs.

Now extracts chunk sizes from the input raster and passes them through
so rasterize uses its _run_dask_numpy path. Also sets use_cuda=True
for dask+cupy inputs.
@github-actions github-actions bot added the performance PR touches performance-sensitive code label Apr 16, 2026
@brendancol brendancol merged commit b36794b into master Apr 16, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

polygon_clip: rasterize mask ignores dask chunks, materializes full array

1 participant