Skip to content

read_geotiff_dask skips default max_pixels region guard when max_pixels=None #1838

@brendancol

Description

@brendancol

Describe the bug

`read_geotiff_dask(..., max_pixels=None)` documents that `None` uses the default cap, but the up-front region guard at `xrspatial/geotiff/init.py:2462` only runs when `max_pixels is not None`:

```python
if max_pixels is not None:
eff_bands = (1 if band is not None else (n_bands if n_bands > 0 else 1))
if full_h * full_w * eff_bands > max_pixels:
raise ValueError(...)
```

Per-chunk reads do substitute `MAX_PIXELS_DEFAULT` for `None` (line 2613-2614), and the VRT chunked path substitutes the default before the upfront guard too (line 4469-4471), but the GeoTIFF dask path does not. Callers can build a lazy graph over a region far larger than the module-wide safety limit; individual chunk reads will only fail at compute time rather than at graph construction.

Expected behavior

`max_pixels=None` should apply the module default to the up-front region check, matching the eager and VRT paths.

Fix

Substitute `MAX_PIXELS_DEFAULT` for `None` before the up-front guard in `read_geotiff_dask`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions