Skip to content

Re-export open_geotiff and to_geotiff from the top-level xrspatial namespace #3005

@brendancol

Description

@brendancol

Reason or Problem

open_geotiff and to_geotiff are the two public entry points of the geotiff subpackage, but today you can only import them from the subpackage:

from xrspatial.geotiff import open_geotiff, to_geotiff

Every other public function in xarray-spatial imports directly from the top level (from xrspatial import slope). The GeoTIFF entry points are the odd ones out, which trips people up.

Proposal

Re-export both functions from the top-level xrspatial package so either spelling works:

from xrspatial import open_geotiff, to_geotiff          # new, shorter
from xrspatial.geotiff import open_geotiff, to_geotiff   # still works

Design: Add two import lines to xrspatial/__init__.py next to the existing top-level re-exports. The functions themselves don't change.

Value: Same import style everywhere, and shorter imports for the GeoTIFF entry points.

Drawbacks

None worth flagging. The subpackage import keeps working, so nothing breaks.

Alternatives

Leave it as is and document the subpackage path, which keeps the inconsistency.

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiAPI design and consistencyenhancementNew feature or requestgeotiffGeoTIFF 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