gjoseph92 / stackstac

Turn a STAC catalog into a dask-based xarray
https://stackstac.readthedocs.io
MIT License
238 stars 49 forks source link

Support Sequence[PystacItem] as an argument to stackstac.stack() method #163

Closed philvarner closed 2 years ago

philvarner commented 2 years ago

The stack method currently supports numerous forms of data for the items parameter:

def stack(
    items: Union[ItemCollectionIsh, ItemIsh],
...

ItemSequence = Sequence[ItemDict]

ItemIsh = Union[SatstacItem, PystacItem, ItemDict]
ItemCollectionIsh = Union[
    SatstacItemCollection, PystacCatalog, PystacItemCollection, ItemSequence
]

However, one thing it doesn't support is a Sequence[PystacItem]. This would allow clean integration with pystac-client:

stack = stackstac.stack(list(Client(...).search().items()))

(also the get_all_items() method in the docs is now deprecated in favor of the items() iterator)

This change would also require a change to:

def items_to_plain(items: Union[ItemCollectionIsh, ItemIsh]) -> ItemSequence:

to handle the case where the Sequence is either a dict representing an item or a pystac.Item.

philvarner commented 2 years ago

🎉