diff --git a/lambda/lambda_function.py b/lambda/lambda_function.py index b65d711..d2871b0 100644 --- a/lambda/lambda_function.py +++ b/lambda/lambda_function.py @@ -60,8 +60,15 @@ def lambda_handler(event, context): items = [] if 'sentinel-s1' in collection: - scene = SentinelSTAC(collection, metadata) - item = scene.to_stac(base_url='s3://%s/%s' % (collection, metadata['path'])) + base_url = 's3://%s/%s' % (collection, metadata['path']) + fnames = [f"{base_url}/{a}" for a in metadata['filenameMap'].values() if 'annotation' in a and 'calibration' not in a] + md = { + 'id': metadata['id'], + 'coordinates': metadata['footprint']['coordinates'], + 'filenames': fnames + } + scene = SentinelSTAC(collection, md) + item = scene.to_stac() items.append(item) else: # there should never be more than one tile diff --git a/requirements-lambda.txt b/requirements-lambda.txt index c625163..e6b0ea9 100644 --- a/requirements-lambda.txt +++ b/requirements-lambda.txt @@ -1,5 +1,3 @@ -#pyproj==2.4.1 -#shapely~=1.6.4.post2 -boto3-utils==0.0.3 +boto3-utils==0.1.2 xmljson~=0.2.0 requests>=2.18.1 diff --git a/samples/sentinel-s2-l1c_item.json b/samples/sentinel-s2-l1c_item.json deleted file mode 100644 index 2a32dff..0000000 --- a/samples/sentinel-s2-l1c_item.json +++ /dev/null @@ -1,182 +0,0 @@ -{ - "name": "S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332", - "id": "b69f6809-81d0-440f-a2f4-60aa352b2e6b", - "path": "products/2015/10/23/S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332", - "timestamp": "2015-10-23T16:23:32.027Z", - "datatakeIdentifier": "GS2A_20151023T162332_001753_N02.04", - "sciHubIngestion": "2016-12-19T17:31:13.879Z", - "s3Ingestion": "2016-12-19T17:48:21.313Z", - "tiles": [ - { - "path": "tiles/16/S/FJ/2015/10/23/0", - "timestamp": "2015-10-23T16:23:33.456Z", - "utmZone": 16, - "latitudeBand": "S", - "gridSquare": "FJ", - "datastrip": { - "id": "S2A_OPER_MSI_L1C_DS_EPA__20161215T145224_S20151023T162333_N02.04", - "path": "products/2015/10/23/S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332/datastrip/0" - } - }, - { - "path": "tiles/16/T/FK/2015/10/23/0", - "timestamp": "2015-10-23T16:23:33.456Z", - "utmZone": 16, - "latitudeBand": "T", - "gridSquare": "FK", - "datastrip": { - "id": "S2A_OPER_MSI_L1C_DS_EPA__20161215T145224_S20151023T162333_N02.04", - "path": "products/2015/10/23/S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332/datastrip/0" - } - }, - { - "path": "tiles/17/S/LD/2015/10/23/0", - "timestamp": "2015-10-23T16:23:33.456Z", - "utmZone": 17, - "latitudeBand": "S", - "gridSquare": "LD", - "datastrip": { - "id": "S2A_OPER_MSI_L1C_DS_EPA__20161215T145224_S20151023T162333_N02.04", - "path": "products/2015/10/23/S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332/datastrip/0" - } - }, - { - "path": "tiles/17/S/LC/2015/10/23/0", - "timestamp": "2015-10-23T16:23:33.456Z", - "utmZone": 17, - "latitudeBand": "S", - "gridSquare": "LC", - "datastrip": { - "id": "S2A_OPER_MSI_L1C_DS_EPA__20161215T145224_S20151023T162333_N02.04", - "path": "products/2015/10/23/S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332/datastrip/0" - } - }, - { - "path": "tiles/16/S/GH/2015/10/23/0", - "timestamp": "2015-10-23T16:23:33.456Z", - "utmZone": 16, - "latitudeBand": "S", - "gridSquare": "GH", - "datastrip": { - "id": "S2A_OPER_MSI_L1C_DS_EPA__20161215T145224_S20151023T162333_N02.04", - "path": "products/2015/10/23/S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332/datastrip/0" - } - }, - { - "path": "tiles/16/S/FH/2015/10/23/0", - "timestamp": "2015-10-23T16:23:33.456Z", - "utmZone": 16, - "latitudeBand": "S", - "gridSquare": "FH", - "datastrip": { - "id": "S2A_OPER_MSI_L1C_DS_EPA__20161215T145224_S20151023T162333_N02.04", - "path": "products/2015/10/23/S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332/datastrip/0" - } - }, - { - "path": "tiles/17/S/KD/2015/10/23/0", - "timestamp": "2015-10-23T16:23:33.456Z", - "utmZone": 17, - "latitudeBand": "S", - "gridSquare": "KD", - "datastrip": { - "id": "S2A_OPER_MSI_L1C_DS_EPA__20161215T145224_S20151023T162333_N02.04", - "path": "products/2015/10/23/S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332/datastrip/0" - } - }, - { - "path": "tiles/17/T/ME/2015/10/23/0", - "timestamp": "2015-10-23T16:23:33.456Z", - "utmZone": 17, - "latitudeBand": "T", - "gridSquare": "ME", - "datastrip": { - "id": "S2A_OPER_MSI_L1C_DS_EPA__20161215T145224_S20151023T162333_N02.04", - "path": "products/2015/10/23/S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332/datastrip/0" - } - }, - { - "path": "tiles/17/T/KE/2015/10/23/0", - "timestamp": "2015-10-23T16:23:33.456Z", - "utmZone": 17, - "latitudeBand": "T", - "gridSquare": "KE", - "datastrip": { - "id": "S2A_OPER_MSI_L1C_DS_EPA__20161215T145224_S20151023T162333_N02.04", - "path": "products/2015/10/23/S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332/datastrip/0" - } - }, - { - "path": "tiles/17/S/MC/2015/10/23/0", - "timestamp": "2015-10-23T16:23:33.456Z", - "utmZone": 17, - "latitudeBand": "S", - "gridSquare": "MC", - "datastrip": { - "id": "S2A_OPER_MSI_L1C_DS_EPA__20161215T145224_S20151023T162333_N02.04", - "path": "products/2015/10/23/S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332/datastrip/0" - } - }, - { - "path": "tiles/17/T/LE/2015/10/23/0", - "timestamp": "2015-10-23T16:23:33.456Z", - "utmZone": 17, - "latitudeBand": "T", - "gridSquare": "LE", - "datastrip": { - "id": "S2A_OPER_MSI_L1C_DS_EPA__20161215T145224_S20151023T162333_N02.04", - "path": "products/2015/10/23/S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332/datastrip/0" - } - }, - { - "path": "tiles/17/S/KC/2015/10/23/0", - "timestamp": "2015-10-23T16:23:33.456Z", - "utmZone": 17, - "latitudeBand": "S", - "gridSquare": "KC", - "datastrip": { - "id": "S2A_OPER_MSI_L1C_DS_EPA__20161215T145224_S20151023T162333_N02.04", - "path": "products/2015/10/23/S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332/datastrip/0" - } - }, - { - "path": "tiles/16/S/GJ/2015/10/23/0", - "timestamp": "2015-10-23T16:23:33.456Z", - "utmZone": 16, - "latitudeBand": "S", - "gridSquare": "GJ", - "datastrip": { - "id": "S2A_OPER_MSI_L1C_DS_EPA__20161215T145224_S20151023T162333_N02.04", - "path": "products/2015/10/23/S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332/datastrip/0" - } - }, - { - "path": "tiles/16/T/GK/2015/10/23/0", - "timestamp": "2015-10-23T16:23:33.456Z", - "utmZone": 16, - "latitudeBand": "T", - "gridSquare": "GK", - "datastrip": { - "id": "S2A_OPER_MSI_L1C_DS_EPA__20161215T145224_S20151023T162333_N02.04", - "path": "products/2015/10/23/S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332/datastrip/0" - } - }, - { - "path": "tiles/17/S/MD/2015/10/23/0", - "timestamp": "2015-10-23T16:23:33.456Z", - "utmZone": 17, - "latitudeBand": "S", - "gridSquare": "MD", - "datastrip": { - "id": "S2A_OPER_MSI_L1C_DS_EPA__20161215T145224_S20151023T162333_N02.04", - "path": "products/2015/10/23/S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332/datastrip/0" - } - } - ], - "datastrips": [ - { - "id": "S2A_OPER_MSI_L1C_DS_EPA__20161215T145224_S20151023T162333_N02.04", - "path": "products/2015/10/23/S2A_OPER_PRD_MSIL1C_PDMC_20161219T165601_R040_V20151023T162332_20151023T162332/datastrip/0" - } - ] -} \ No newline at end of file diff --git a/samples/sentinel-s2-l2a_item.json b/samples/sentinel-s2-l2a_item.json new file mode 100644 index 0000000..2d40cc6 --- /dev/null +++ b/samples/sentinel-s2-l2a_item.json @@ -0,0 +1 @@ +{"type":"Feature","stac_version":"0.9.0","stac_extensions":["dtr","sat","eo"],"id":"S2B_23VMF_20200102_0_L2A","collection":"sentinel-s2-l2a","bbox":[-46.76845394249839,58.962547187342146,-44.82743654507847,59.538226395172046],"geometry":{"type":"Polygon","coordinates":[[[-44.83032148699731,58.962547187342146],[-46.758918274502335,59.34318006505064],[-46.76845394249839,59.52639001577173],[-44.82743654507847,59.538226395172046],[-44.83032148699731,58.962547187342146]]]},"properties":{"constellation":"sentinel-2","instruments":["msi"],"eo:gsd":10,"eo:bands":[{"full_width_half_max":0.027,"center_wavelength":0.4439,"name":"B01","gsd":60,"common_name":"coastal"},{"full_width_half_max":0.098,"center_wavelength":0.4966,"name":"B02","gsd":10,"common_name":"blue"},{"full_width_half_max":0.045,"center_wavelength":0.56,"name":"B03","gsd":10,"common_name":"green"},{"full_width_half_max":0.038,"center_wavelength":0.6645,"name":"B04","gsd":10,"common_name":"red"},{"full_width_half_max":0.019,"center_wavelength":0.7039,"name":"B05","gsd":20},{"full_width_half_max":0.018,"center_wavelength":0.7402,"name":"B06","gsd":20},{"full_width_half_max":0.028,"center_wavelength":0.7825,"name":"B07","gsd":20},{"full_width_half_max":0.145,"center_wavelength":0.8351,"name":"B08","gsd":10,"common_name":"nir"},{"full_width_half_max":0.033,"center_wavelength":0.8648,"name":"B8A","gsd":20},{"full_width_half_max":0.026,"center_wavelength":0.945,"name":"B09","gsd":60},{"full_width_half_max":0.075,"center_wavelength":1.3735,"name":"B10","gsd":60,"common_name":"cirrus"},{"full_width_half_max":0.143,"center_wavelength":1.6137,"name":"B11","gsd":20,"common_name":"swir16"},{"full_width_half_max":0.242,"center_wavelength":2.22024,"name":"B12","gsd":20,"common_name":"swir22"}],"sat:off_nadir_angle":0,"datetime":"2020-01-02T14:35:53.297000+00:00","platform":"sentinel-2b","eo:cloud_cover":0,"sentinel:utm_zone":23,"sentinel:latitude_band":"V","sentinel:grid_square":"MF","sentinel:sequence":"0","sentinel:product_id":"S2B_MSIL2A_20200102T143519_N0213_R139_T23VMF_20200102T163733","created":"2020-01-03T22:48:53.994Z","updated":"2020-01-03T22:48:53.994Z"},"assets":{"thumbnail":{"title":"Thumbnail","type":"image/png","roles":["thumbnail"],"href":"https://cirrus-omega-data.s3.us-west-2.amazonaws.com/sentinel-s2-l2a/2020/S2B_23VMF_20200102_0_L2A/preview.jpg"},"info":{"title":"Original JSON metadata","type":"application/json","roles":["metadata"],"href":"https://cirrus-omega-data.s3.us-west-2.amazonaws.com/sentinel-s2-l2a/2020/S2B_23VMF_20200102_0_L2A/tileInfo.json"},"metadata":{"title":"Original XML metadata","type":"application/xml","roles":["metadata"],"href":"https://cirrus-omega-data.s3.us-west-2.amazonaws.com/sentinel-s2-l2a/2020/S2B_23VMF_20200102_0_L2A/metadata.xml"},"overview":{"title":"True color image","type":"image/jp2","roles":["overview"],"eo:bands":[3,2,1],"href":"https://cirrus-omega-data.s3.us-west-2.amazonaws.com/sentinel-s2-l2a/2020/S2B_23VMF_20200102_0_L2A/TCI.tif"},"B01":{"title":"Band 1 (coastal)","type":"image/jp2","roles":["analytic"],"eo:bands":[0],"href":"https://cirrus-omega-data.s3.us-west-2.amazonaws.com/sentinel-s2-l2a/2020/S2B_23VMF_20200102_0_L2A/B01.tif"},"B02":{"title":"Band 2 (blue)","type":"image/jp2","roles":["analytic"],"eo:bands":[2],"href":"https://cirrus-omega-data.s3.us-west-2.amazonaws.com/sentinel-s2-l2a/2020/S2B_23VMF_20200102_0_L2A/B02.tif"},"B03":{"title":"Band 3 (green)","type":"image/jp2","roles":["analytic"],"eo:bands":[2],"href":"https://cirrus-omega-data.s3.us-west-2.amazonaws.com/sentinel-s2-l2a/2020/S2B_23VMF_20200102_0_L2A/B03.tif"},"B04":{"title":"Band 4 (red)","type":"image/jp2","roles":["analytic"],"eo:bands":[3],"href":"https://cirrus-omega-data.s3.us-west-2.amazonaws.com/sentinel-s2-l2a/2020/S2B_23VMF_20200102_0_L2A/B04.tif"},"B05":{"title":"Band 5","type":"image/jp2","roles":["analytic"],"eo:bands":[4],"href":"https://cirrus-omega-data.s3.us-west-2.amazonaws.com/sentinel-s2-l2a/2020/S2B_23VMF_20200102_0_L2A/B05.tif"},"B06":{"title":"Band 6","type":"image/jp2","roles":["analytic"],"eo:bands":[5],"href":"https://cirrus-omega-data.s3.us-west-2.amazonaws.com/sentinel-s2-l2a/2020/S2B_23VMF_20200102_0_L2A/B06.tif"},"B07":{"title":"Band 7","type":"image/jp2","roles":["analytic"],"eo:bands":[6],"href":"https://cirrus-omega-data.s3.us-west-2.amazonaws.com/sentinel-s2-l2a/2020/S2B_23VMF_20200102_0_L2A/B07.tif"},"B08":{"title":"Band 8 (nir)","type":"image/jp2","roles":["analytic"],"eo:bands":[7],"href":"https://cirrus-omega-data.s3.us-west-2.amazonaws.com/sentinel-s2-l2a/2020/S2B_23VMF_20200102_0_L2A/B08.tif"},"B8A":{"title":"Band 8A","type":"image/jp2","roles":["analytic"],"eo:bands":[8],"href":"https://cirrus-omega-data.s3.us-west-2.amazonaws.com/sentinel-s2-l2a/2020/S2B_23VMF_20200102_0_L2A/B8A.tif"},"B09":{"title":"Band 9","type":"image/jp2","roles":["analytic"],"eo:bands":[9],"href":"https://cirrus-omega-data.s3.us-west-2.amazonaws.com/sentinel-s2-l2a/2020/S2B_23VMF_20200102_0_L2A/B09.tif"},"B10":{"title":"Band 10 (cirrus)","type":"image/jp2","roles":["analytic"],"eo:bands":[10],"href":"s3://sentinel-s2-l2a/tiles/23/V/MF/2020/1/2/0/R60m/B10.jp2"},"B11":{"title":"Band 11 (swir16)","type":"image/jp2","roles":["analytic"],"eo:bands":[11],"href":"https://cirrus-omega-data.s3.us-west-2.amazonaws.com/sentinel-s2-l2a/2020/S2B_23VMF_20200102_0_L2A/B11.tif"},"B12":{"title":"Band 12 (swir22)","type":"image/jp2","roles":["analytic"],"eo:bands":[12],"href":"https://cirrus-omega-data.s3.us-west-2.amazonaws.com/sentinel-s2-l2a/2020/S2B_23VMF_20200102_0_L2A/B12.tif"}},"links":[{"rel":"self","href":"https://fn8d3qzbhk.execute-api.us-west-2.amazonaws.com/omega/collections/sentinel-s2-l2a/items/S2B_23VMF_20200102_0_L2A"},{"rel":"parent","href":"https://fn8d3qzbhk.execute-api.us-west-2.amazonaws.com/omega/collections/sentinel-s2-l2a"},{"rel":"collection","href":"https://fn8d3qzbhk.execute-api.us-west-2.amazonaws.com/omega/collections/sentinel-s2-l2a"},{"rel":"root","href":"https://fn8d3qzbhk.execute-api.us-west-2.amazonaws.com/omega/"}]} \ No newline at end of file