From a7ffe3e992a76ac2461d19c1795bb7a283cd0d4d Mon Sep 17 00:00:00 2001 From: Matthew Hanson Date: Sun, 24 Jan 2021 23:13:03 -0500 Subject: [PATCH 1/5] allow reading in of ItemCollection without collection, resolves #65 --- CHANGELOG.md | 5 +++++ satstac/itemcollection.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c71866..5a6749c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [v0.4.1] - 2021-01-24 + +### Changed +- Allow reading in of ItemCollections without collections + ## [v0.4.0] - 2020-06-11 ### Added diff --git a/satstac/itemcollection.py b/satstac/itemcollection.py index 25cf48e..2ffc74d 100644 --- a/satstac/itemcollection.py +++ b/satstac/itemcollection.py @@ -55,7 +55,7 @@ def open(cls, filename): data = json.loads(data) else: raise STACError('%s does not exist locally' % filename) - collections = [Collection(col) for col in data['collections']] + collections = [Collection(col) for col in data.get('collections', [])] items = [Item(feature) for feature in data['features']] return cls(items, collections=collections) From 11bd3ae4a6654ca7d17e54f26153db990b1de09d Mon Sep 17 00:00:00 2001 From: Matthew Hanson Date: Sun, 24 Jan 2021 23:16:07 -0500 Subject: [PATCH 2/5] updated changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a6749c..139fe34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [v0.4.1] - 2021-01-24 +### Added +- User can now provide custom headers to download function + ### Changed - Allow reading in of ItemCollections without collections From b428b529d7bc894756c6bd4753eea9d05189aec6 Mon Sep 17 00:00:00 2001 From: Matthew Hanson Date: Mon, 25 Jan 2021 00:00:11 -0500 Subject: [PATCH 3/5] update default STAC_VERSION --- satstac/catalog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/satstac/catalog.py b/satstac/catalog.py index 28f95e7..12a95c7 100644 --- a/satstac/catalog.py +++ b/satstac/catalog.py @@ -4,7 +4,7 @@ from .version import __version__ from .thing import Thing, STACError -STAC_VERSION = os.getenv('STAC_VERSION', '1.0.0-beta.1') +STAC_VERSION = os.getenv('STAC_VERSION', '1.0.0-beta.2') class Catalog(Thing): From 27f7356b71f3d30d0d4dafcf06711e67006b463a Mon Sep 17 00:00:00 2001 From: Matthew Hanson Date: Mon, 25 Jan 2021 00:00:33 -0500 Subject: [PATCH 4/5] add missing fields to saved itemcollection, add id and description keywords --- satstac/itemcollection.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/satstac/itemcollection.py b/satstac/itemcollection.py index 2ffc74d..125397c 100644 --- a/satstac/itemcollection.py +++ b/satstac/itemcollection.py @@ -3,6 +3,7 @@ import requests from logging import getLogger +from .catalog import STAC_VERSION from .collection import Collection from .item import Item from .thing import STACError @@ -129,18 +130,23 @@ def assets_definition(self): txt += ''.join([f"{vals[i]:{w[i]}}" for i in range(len(w))]) + '\n' return txt - def save(self, filename): + def save(self, filename, **kwargs): """ Save scene metadata """ with open(filename, 'w') as f: - f.write(json.dumps(self.geojson())) + f.write(json.dumps(self.geojson(**kwargs))) - def geojson(self): + def geojson(self, id='STAC', description='Single file STAC'): """ Get Items as GeoJSON FeatureCollection """ features = [s._data for s in self._items] geoj = { + 'id': id, + 'description': description, + 'stac_version': STAC_VERSION, + 'stac_extensions': ['single-file-stac'], 'type': 'FeatureCollection', 'features': features, 'collections': [c._data for c in self._collections], + 'links': [] } return geoj From ffd61e557a0cecab57368483f1125ad2ea95e84d Mon Sep 17 00:00:00 2001 From: Matthew Hanson Date: Mon, 25 Jan 2021 00:00:49 -0500 Subject: [PATCH 5/5] update CHANGELOG and bump version --- CHANGELOG.md | 5 +++++ satstac/version.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 139fe34..e7001e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added - User can now provide custom headers to download function +- `id` and `description` keywords added to itemcollection.save() and itemcollection.geojson() for user to supply values to save single file STAC ### Changed - Allow reading in of ItemCollections without collections +- Default STAC_VERSION updated to 1.0.0-beta.2 + +### Fixed +- Saved ItemCollections now adhere to STAC single-file-stac spec ## [v0.4.0] - 2020-06-11 diff --git a/satstac/version.py b/satstac/version.py index abeeedb..f0ede3d 100644 --- a/satstac/version.py +++ b/satstac/version.py @@ -1 +1 @@ -__version__ = '0.4.0' +__version__ = '0.4.1'