Skip to content

morph_gradient, white_tophat, black_tophat missing from .xrs accessor #3399

@brendancol

Description

@brendancol

Reason or Problem

The .xrs accessor exposes only four of the seven public morphology functions. morph_erode, morph_dilate, morph_opening, and morph_closing have accessor methods on both XrsSpatialDataArrayAccessor and XrsSpatialDatasetAccessor. morph_gradient, morph_white_tophat, and morph_black_tophat do not.

All seven functions are public. They are re-exported from xrspatial/__init__.py, documented with full docstrings, and covered by tests (test_morphology_derived.py). Calling da.xrs.morph_erode(...) works, but da.xrs.morph_gradient(...) raises AttributeError. The accessor surface is inconsistent within one function family.

This looks like an oversight rather than a design choice. The four base ops landed in #949, their accessor methods in #1042. The three derived ops landed later in #1026, and the accessor was never updated to match.

Proposal

Add accessor methods for the three derived functions to both accessor classes, following the existing forwarding pattern:

def morph_gradient(self, **kwargs):
    from .morphology import morph_gradient
    return morph_gradient(self._obj, **kwargs)

Value: every public morphology function becomes reachable through .xrs.

Drawbacks

None. The change is additive and does not touch existing methods.

Stakeholders and Impacts

Users of the .xrs accessor for morphological operations. No impact on the direct function API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiAPI design and consistencyenhancementNew feature or request

    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