Skip to content

Direct reader backends default to masking nodata while open_geotiff defaults to unmasked #2976

@brendancol

Description

@brendancol

Describe the bug

The direct reader backends default to masking nodata, but the public open_geotiff defaults to unmasked reads. Call a backend directly with no mask_nodata argument and you get a different dtype and different values than open_geotiff returns. The divergence is silent.

open_geotiff sets masked: bool = False and documents rioxarray-compatible unmasked reads. The wrapper forwards mask_nodata=masked to the backends explicitly on every dispatch path (GPU, dask, VRT, eager). But the three backend entry points each keep mask_nodata: bool = True as their own default:

  • _read_geotiff_dask in xrspatial/geotiff/_backends/dask.py
  • _read_geotiff_gpu in xrspatial/geotiff/_backends/gpu.py
  • _read_vrt in xrspatial/geotiff/_backends/vrt.py

To Reproduce

A public chunked read returns int16 with -9999 preserved (unmasked). A direct _read_geotiff_dask() call on the same file returns float64 with NaN (masked). Same split for _read_geotiff_gpu and _read_vrt.

Expected behavior

A bare backend call with no mask_nodata argument should match open_geotiff: keep the source dtype, preserve the nodata sentinel, don't substitute NaN. The three backend defaults should be False.

Additional context

The public wrapper always passes mask_nodata=masked explicitly, so the default only affects direct callers. The internal callers (GPU-to-dask fallback, dask-to-VRT dispatch) forward the value explicitly too, so flipping the default only touches code that calls a backend directly without the kwarg.

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiAPI design and consistencybugSomething isn't workinggeotiffGeoTIFF module

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions