-
Notifications
You must be signed in to change notification settings - Fork 25
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
add support for satstac.ItemCollection #29
Changes from 2 commits
b2c215e
f96ac6a
a3d1e11
b257da9
1e90ce5
38cbe51
19fd65d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,12 +33,15 @@ def __init__(self, stac_obj, **kwargs): | |
else: | ||
raise ValueError( | ||
"Expected %s instance, got: %s" | ||
% (type(self._stac_cls), type(stac_obj)) | ||
% (self._stac_cls, type(stac_obj)) | ||
) | ||
|
||
metadata = self._get_metadata(**kwargs.pop("metadata", {})) | ||
|
||
name = kwargs.pop("name", self._stac_obj.id) | ||
try: | ||
name = kwargs.pop("name", self._stac_obj.id) | ||
except AttributeError: | ||
name = str(type(self._stac_obj)) | ||
|
||
super().__init__(name=name, metadata=metadata, **kwargs) | ||
|
||
|
@@ -125,6 +128,31 @@ def _get_metadata(self, **kwargs): | |
) | ||
|
||
|
||
class StacItemCollection(AbstractStacCatalog): | ||
""" | ||
Intake Catalog represeting a STAC ItemCollection | ||
""" | ||
|
||
name = "stac_item_collection" | ||
_stac_cls = satstac.ItemCollection | ||
|
||
def _load(self): | ||
""" | ||
Load the STAC Item Collection. | ||
""" | ||
for item in self._stac_obj: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @matthewhanson - I could use a sanity check on this section.
Alternatively, we can/should we be grouping these items by collection? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure grouping is necessary. The most common use case I think is a catalog with a single collection of data. Additionally, a user might want to group them according to any of the other metadata fields, so I think we can leave it to the user to decide how to sort/use them. |
||
self._entries[item.id] = LocalCatalogEntry( | ||
name=item.id, | ||
description="", | ||
driver=StacItem, | ||
catalog=self, | ||
args={"stac_obj": item}, | ||
) | ||
|
||
def _get_metadata(self, **kwargs): | ||
return kwargs | ||
|
||
|
||
class StacCollection(AbstractStacCatalog): | ||
""" | ||
Intake Catalog represeting a STAC Collection | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matthewhanson - here is another place where we were tripped up while using a
ItemCollection
. There is not anid
attribute on the class object. Not sure if it is possible, but it would be nice ifItemCollection
inherited fromsatstac.Thing
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jhamman In sat-stac an ItemCollection isn't really a STAC ItemCollection, it's more of a Single File STAC as per the extension:
https://github.com/radiantearth/stac-spec/tree/dev/extensions/single-file-stac
The idea behind this was that a self-contained STAC catalog would be like a regular STAC catalog, except as you pointed out there's no
id
, nor are there any other catalog fields:https://github.com/radiantearth/stac-spec/blob/dev/catalog-spec/catalog-spec.md#catalog-fields
I've posted an issue for STAC recommending that all the Catalog fields get added to the Single File STAC extension:
radiantearth/stac-spec#691