Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pystac.ItemCollection #64

Merged
merged 1 commit into from
Jul 7, 2021

Conversation

TomAugspurger
Copy link
Contributor

stac-utils/pystac#430 implemented pystac.ItemCollection, which is being removed from pystac-client in the next release. This PR adds similar handling for pystac.ItemCollection.

I haven't updated the documentation notebooks yet, since pystac and psytac-client are still in a release-candidate / beta. Once they're released I think the notebooks can be updated.

Copy link
Owner

@gjoseph92 gjoseph92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks for keeping up to date with all the rapid STAC changes.

We should probably bump the pystac dependency to 1.0 once that's released, no?

@gjoseph92 gjoseph92 merged commit c431e09 into gjoseph92:main Jul 7, 2021
@TomAugspurger
Copy link
Contributor Author

We should probably bump the pystac dependency to 1.0 once that's released, no?

Yeah, I think so. Both pystac-client and intake-stac will require pystac>=1.0 for their next releases.

@TomAugspurger TomAugspurger deleted the fix/pystac-itemcollection branch July 7, 2021 18:57
@scottyhq
Copy link
Contributor

@TomAugspurger @gjoseph92 I was just testing this out, but the iteration syntax needs to be changed to work with PyStac.ItemCollection. You can test with the basic example:

import pystac_client
import stackstac

URL = "https://earth-search.aws.element84.com/v0"
catalog = pystac_client.Client.open(URL)

lon, lat = -105.78, 35.79

results = catalog.search(
    intersects=dict(type="Point", coordinates=[lon, lat]),
    collections=["sentinel-s2-l2a-cogs"],
    datetime="2020-04-01/2020-05-01"
)

stack = stackstac.stack(results.get_all_items())
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<timed exec> in <module>

/srv/conda/envs/notebook/lib/python3.8/site-packages/stackstac/stack.py in stack(items, assets, epsg, resolution, bounds, bounds_latlon, snap_bounds, resampling, chunksize, dtype, fill_value, rescale, sortby_date, xy_coords, properties, band_coords, gdal_env, errors_as_nodata, reader)
    278         automatically computed from the items you pass in.
    279     """
--> 280     plain_items = items_to_plain(items)
    281 
    282     if sortby_date is not False:

/srv/conda/envs/notebook/lib/python3.8/site-packages/stackstac/stac_types.py in items_to_plain(items)
    157         return [item.to_dict() for item in items.features]
    158 
--> 159     raise TypeError(f"Unrecognized STAC collection type {type(items)}: {items!r}")

TypeError: Unrecognized STAC collection type <class 'pystac.item_collection.ItemCollection'>: <pystac.item_collection.ItemCollection object at 0x7f10d3d833a0>

Thoughts on just having some basic pytest tests to catch stuff like this before all the ideas for testing here #26 ?

@gjoseph92 gjoseph92 added the needs-future-test Add a test for this in the future, once tests exist (#26) label Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-future-test Add a test for this in the future, once tests exist (#26)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants