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

TypeError: Unrecognized STAC collection type <class 'pystac.item_collection.ItemCollection'> #124

Closed
cOsprey opened this issue Jan 31, 2022 · 4 comments

Comments

@cOsprey
Copy link

cOsprey commented Jan 31, 2022

I am trying to use stackstac ( Windows, virtual environment) but getting this error. Also I tried using in google colab but when I do pip install stackstac,older version 0.1.1 is installed.
Error on windows:

TypeError                                 Traceback (most recent call last)
File <timed exec>:1, in <module>

File C:\ProgramData\Anaconda3\envs\a2\lib\site-packages\stackstac\stack.py:278, 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)
     20 def stack(
     21     items: Union[ItemCollectionIsh, ItemIsh],
     22     assets: Optional[Union[List[str], AbstractSet[str]]] = frozenset(
   (...)
     43     reader: Type[Reader] = AutoParallelRioReader,
     44 ) -> xr.DataArray:
     45     """
     46     Create an `xarray.DataArray` of all the STAC items, reprojected to the same grid and stacked by time.
     47 
   (...)
    276         automatically computed from the items you pass in.
    277     """
--> 278     plain_items = items_to_plain(items)
    280     if sortby_date is not False:
    281         plain_items = sorted(
    282             plain_items,
    283             key=lambda item: item["properties"].get("datetime", "") or "",
    284             reverse=sortby_date == "desc",
    285         )

File C:\ProgramData\Anaconda3\envs\a2\lib\site-packages\stackstac\stac_types.py:163, in items_to_plain(items)
    160 if isinstance(items, PystacItemCollection):
    161     return [item.to_dict() for item in items]
--> 163 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 0x0000028DF16140D0>`
@gjoseph92
Copy link
Owner

What versions of stackstac, pystac, and pystac-client are installed?

Can you please post a minimal, complete reproducible example of how you're creating the ItemCollection you're passing into stackstac?

Lastly, can you confirm that

from pystac import ItemCollection
isinstance(<thing you're passing into stackstac>, ItemCollection)

is True?

@cOsprey
Copy link
Author

cOsprey commented Jan 31, 2022

I was using python 3.9 on windows, shifted to ubuntu & python 3.8. I am not getting error now.
Sorry I can't share the version as I was using anaconda and removed the environment.
It would be great to have a requirements.txt for users to install.

@gjoseph92
Copy link
Owner

It would be great to have a requirements.txt for users to install.

Installing stackstac installs all the necessary requirements. pystac, satstac, etc. are all optional requirements; you don't need them in order to use stackstac. You can always just pass in a a plain dict of STAC items. I'm guessing you were using a pre-1.0 version of pystac or something?

@cOsprey
Copy link
Author

cOsprey commented Jan 31, 2022

@gjoseph92 , thanks for your support. Possibly I might be using an older version of pystac, I also tried using the bounds_latlon function but got TypeError: cannot unpack non-iterable NoneType object. Have added the ipynb file in the zip attached.
basic.zip

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants