Skip to content

reproject: missing _validate_raster on public API inputs #1431

@brendancol

Description

@brendancol

Description

Three public functions in xrspatial.reproject validate their input only with isinstance(_, xr.DataArray). Bad input (1-D DataArray, complex dtype, etc.) plunges into helpers and fails with cryptic KeyError / IndexError instead of a clean ValueError from the public API.

Function Site Bad input today
reproject() xrspatial/reproject/__init__.py:524-528 1-D DataArray -> KeyError in _find_spatial_dims
merge() xrspatial/reproject/__init__.py:1350-1354 per-element bad raster -> AttributeError
geoid_height_raster() xrspatial/reproject/_vertical.py:212 non-DataArray -> AttributeError on .coords

Expected behavior

Each public function calls _validate_raster on its DataArray input(s) before any helper accesses .coords / .dims.

Proposed fix

Replace the isinstance guard / dimension probe with _validate_raster(raster, func_name=..., name=..., ndim=(2, 3)). For merge, validate each element of rasters in the iteration loop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginput-validationInput validation and error messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions