Skip to content

Dask geodesic aspect skips the chunk memory guard #2840

@brendancol

Description

@brendancol

Describe the bug

The Dask path in geodesic aspect skips the chunk memory guard. In xrspatial/aspect.py, the method='geodesic' branch checks is_dask and skips _check_geodesic_memory for any Dask-backed array. So a Dask array whose single chunk spans the whole raster gets no guard at all, and it can still OOM at compute time.

The slope module already handles this. slope() calls _check_geodesic_memory_backend_aware(agg, func_name='slope') (in xrspatial/slope.py). That helper is backend-aware: for eager numpy/cupy it sizes against the full raster, and for Dask it sizes against the largest chunk plus the map_overlap halo. A single huge chunk has no memory advantage over eager, so the helper still rejects it.

Aspect should call the same helper so its Dask geodesic path gets a real guard instead of none.

Expected behavior

aspect(raster, method='geodesic') on a Dask array with one chunk covering the whole raster should raise MemoryError when the chunk exceeds available memory, the same way slope() does. A small-chunked raster should still stream through fine.

Additional context

The helper already lives in xrspatial/geodesic.py. The fix swaps the import and replaces the inline is_dask check in aspect with the shared helper.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdaskDask backend / chunked arraysoomOut-of-memory risk with large datasets

    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