Skip to content

Commit

Permalink
Merge pull request #67 from sat-utils/develop
Browse files Browse the repository at this point in the history
publish 0.4.1
  • Loading branch information
matthewhanson committed Jan 25, 2021
2 parents dbd68ef + ffd61e5 commit 40e60f2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [v0.4.1] - 2021-01-24

### 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

### Added
Expand Down
2 changes: 1 addition & 1 deletion satstac/catalog.py
Expand Up @@ -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):
Expand Down
14 changes: 10 additions & 4 deletions satstac/itemcollection.py
Expand Up @@ -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
Expand Down Expand Up @@ -55,7 +56,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)

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion satstac/version.py
@@ -1 +1 @@
__version__ = '0.4.0'
__version__ = '0.4.1'

0 comments on commit 40e60f2

Please sign in to comment.