Skip to content

Commit

Permalink
Issue #11
Browse files Browse the repository at this point in the history
Fixing eo:bands in collection and reference to bands in items
asset_type -> type
  • Loading branch information
fredliporace committed Oct 30, 2018
1 parent b66f96b commit e906a3a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
11 changes: 7 additions & 4 deletions sam/process_new_scene_queue/cbers_2_stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def build_link(rel, href):
link['href'] = href
return link

def build_asset(href, title=None, asset_type=None):
def build_asset(href, title=None, asset_type=None, band_index=None):
"""
Build a asset entry
"""
Expand All @@ -158,7 +158,9 @@ def build_asset(href, title=None, asset_type=None):
if title:
asset['title'] = title
if asset_type:
asset['asset_type'] = asset_type
asset['type'] = asset_type
if band_index is not None:
asset['eo:bands'] = [band_index]
return asset

def build_stac_item_keys(cbers, buckets):
Expand Down Expand Up @@ -259,13 +261,14 @@ def build_stac_item_keys(cbers, buckets):
cbers['meta_file'],
asset_type="text/xml",
title="INPE original metadata")
for band in cbers['bands']:
for index, band in enumerate(cbers['bands']):
band_id = "B" + band
stac_item['assets'][band_id] = \
build_asset(main_prefix + \
cbers['download_url'] + '/' + \
stac_item['id'] + '_BAND' + band + '.tif',
asset_type="image/vnd.stac.geotiff; cloud-optimized=true")
asset_type="image/vnd.stac.geotiff; cloud-optimized=true",
band_index=index)
return stac_item

def create_json_item(stac_item, filename):
Expand Down
16 changes: 10 additions & 6 deletions stac_catalogs/collections/CBERS_4_MUX_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,23 @@
"eo:gsd": 20.0,
"eo:platform": "CBERS-4",
"eo:instrument": "MUX",
"eo:bands": {
"5": {
"eo:bands": [
{
"name": "B5",
"common_name": "blue"
},
"6": {
{
"name": "B6",
"common_name": "green"
},
"7": {
{
"name": "B7",
"common_name": "red"
},
"8": {
{
"name": "B8",
"common_name": "nir"
}
}
]
}
}
3 changes: 3 additions & 0 deletions test/cbers_2_stac_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ def test_build_mux_stac_item_keys(self):
else:
self.fail('Unrecognized rel %s' % link['rel'])

# assets
self.assertEqual(len(smeta['assets']), 6) # 4 bands, 1 metadata, 1 thumbnail

def test_convert_inpe_to_stac(self):
"""test_convert_inpe_to_stac"""

Expand Down

0 comments on commit e906a3a

Please sign in to comment.