Skip to content

Commit 2ffbcc8

Browse files
Merge pull request #9 from sat-utils/develop
release 0.1.0
2 parents 5611c81 + ac5fd82 commit 2ffbcc8

File tree

3 files changed

+57
-21
lines changed

3 files changed

+57
-21
lines changed

README.md

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# sat-stac-sentinel
22

3-
This is a repository used for the creation and maintenance of a [STAC](https://github.com/radiantearth/stac-spec) compliant [Sentinel catalog](https://sentinel-stac.s3.amazonaws.com/catalog.json) for data from the [Sentinel on AWS project](https://registry.opendata.aws/sentinel-2/) (located at s3://sentinel-s2-l1c/).
3+
This is a repository used for the creation and maintenance of a [STAC](https://github.com/radiantearth/stac-spec) compliant [Sentinel catalog](https://sentinel-stac.s3.amazonaws.com/catalog.json) for data from the [Sentinel on AWS project](https://registry.opendata.aws/sentinel-2/) (located at s3://sentinel-s2-l1c/). New STAC Items (i.e., Sentinel scenes) are published to an SNS Topic on AWS: 'arn:aws:sns:eu-central-1:552188055668:sentinel-stac'
4+
5+
The catalog can be browsed at https://sentinel-stac.s3.amazonaws.com/index.html.
46

57
There are two pieces of this repository:
68

@@ -11,6 +13,7 @@ To create the Sentinel STAC catalog located at https://sentinel-stac.s3.amazonaw
1113

1214
## Installation
1315

16+
Sat-stac-landsat can be installed from this repository. It is not in PyPi because it is not a library that is going to be of general use. It exists to create a Landsat STAC catalog and keep it up to date, which is currently ongoing.
1417

1518

1619
## Usage
@@ -42,20 +45,47 @@ This will fetch the latest inventory files from s3://sentinel-inventory/sentinel
4245

4346
This will ingest records either from a local inventory file or, if not provided, the latest bucket inventory files
4447

48+
```
49+
$ sat-stac-sentinel ingest -h
50+
usage: sat-stac-sentinel ingest [-h] [--version] [--log LOG] [--start START]
51+
[--end END] [--prefix PREFIX] [--s3meta]
52+
[--filename FILENAME] [--publish PUBLISH]
53+
catalog
54+
55+
positional arguments:
56+
catalog Catalog that contains the Collection
57+
58+
optional arguments:
59+
-h, --help show this help message and exit
60+
--version Print version and exit
61+
--log LOG 0:all, 1:debug, 2:info, 3:warning, 4:error, 5:critical
62+
(default: 2)
63+
--start START Start date of ingestion (default: None)
64+
--end END End date of ingestion (default: None)
65+
--prefix PREFIX Only ingest scenes with a path starting with prefix
66+
(default: None)
67+
--s3meta Get metadata directly from S3 (requestor pays)
68+
(default: False)
69+
--filename FILENAME Inventory filename to use (default to fetch latest from
70+
bucket Inventory files) (default: None)
71+
--publish PUBLISH ARN to publish new Items to (default: None)
72+
```
4573

4674
The `catalog` argument is the URL to the root catalog which contains a child collection called 'sentinel-2-l1c'. If the 'sentinel-2-l1c' Collection does not exist in the Catalog it will be added. In the case of the catalog maintained by this repo it is located at https://sentinel-stac.s3.amazonaws.com/catalog.json.
4775

4876
If `start` and/or `end` are provided the records are all scanned and only those meeting the date requirements are ingested.
4977

78+
If `filename` is provided it will read the inventory from a file (generated with `sat-stac-sentinel inventory`) instead of retriving the latst bucket inventory files.
5079

51-
## Transforming Sentinel metadata to STAC
80+
The `s3meta` switch controls where the metadata comes from. The default is to get it from a proxy address rather than directly from the bucket (which is requestor pays). The actual cost is negligible, but it tunns out there is little difference in speed so this switch can be left alone.
5281

53-
The data that is ingested by the sat-stac-sentinel CLI starts with
54-
55-
In addition to the inventories, an SNS message is published (arn:aws:sns:us-west-2:274514004127:NewSceneHTML) whenever a new `index.html` appears in the bucket. The sat-stac-sentinel Lambda function listens for this message to get the link of the s3 path with the new scene.
82+
The `publish` switch allows publishing of a new STAC Item to an SNS topic. This should not be used when creating a whole catalog, it will create too many SNS messages.
5683

84+
## Transforming Sentinel metadata to STAC
5785

86+
The data that is ingested by the sat-stac-sentinel CLI starts with bucket inventory files that are retrieved and used to find all of the `tileInfo.json` files (this is the metadata for one Sentinel scene). In addition to the inventories, an SNS message is published (arn:aws:sns:us-west-2:274514004127:NewSceneHTML) whenever a new `index.html` appears in the bucket. The sat-stac-sentinel Lambda function listens for this message to get the link of the s3 path with the new scene.
5887

88+
In either case the tileInfo.json contains all of the data needed to create a STAC Item, however the given geometry is in native coordinates rather than lat/lon. The library reprojects the geometry using EPSG:4326. Additionally, the convex hull is calculated for the geometry. In most cases this doesn't make a difference, however some of the tile geometries can be long and complex. Taking the convex hull is a way to simplify the geometry without impacting search and discovery.
5989

6090
## Development
6191

satstac/sentinel/main.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,13 @@ def add_items(catalog, records, start_date=None, end_date=None, s3meta=False, pr
100100
def read_inventory(filename):
101101
""" Create generator from inventory file """
102102
with open(filename) as f:
103-
f.readline()
103+
line = f.readline()
104+
if 'datetime' not in line:
105+
parts = line.split(',')
106+
yield {
107+
'datetime': parse(parts[0]),
108+
'path': parts[1].strip('\n')
109+
}
104110
for line in f.readlines():
105111
parts = line.split(',')
106112
yield {
@@ -159,19 +165,19 @@ def transform(data):
159165
'info': {'href': op.join(roda_url, 'tileInfo.json')},
160166
'metadata': {'href': op.join(roda_url, 'metadata.xml')},
161167
'tki': {'href': op.join(url, 'TKI.jp2')},
162-
'B01': {'href': op.join(url, 'B01.TIF')},
163-
'B02': {'href': op.join(url, 'B02.TIF')},
164-
'B03': {'href': op.join(url, 'B03.TIF')},
165-
'B04': {'href': op.join(url, 'B04.TIF')},
166-
'B05': {'href': op.join(url, 'B05.TIF')},
167-
'B06': {'href': op.join(url, 'B06.TIF')},
168-
'B07': {'href': op.join(url, 'B07.TIF')},
169-
'B08': {'href': op.join(url, 'B08.TIF')},
170-
'B8A': {'href': op.join(url, 'B08.TIF')},
171-
'B09': {'href': op.join(url, 'B09.TIF')},
172-
'B10': {'href': op.join(url, 'B10.TIF')},
173-
'B11': {'href': op.join(url, 'B11.TIF')},
174-
'B12': {'href': op.join(url, 'B11.TIF')}
168+
'B01': {'href': op.join(url, 'B01.jp2')},
169+
'B02': {'href': op.join(url, 'B02.jp2')},
170+
'B03': {'href': op.join(url, 'B03.jp2')},
171+
'B04': {'href': op.join(url, 'B04.jp2')},
172+
'B05': {'href': op.join(url, 'B05.jp2')},
173+
'B06': {'href': op.join(url, 'B06.jp2')},
174+
'B07': {'href': op.join(url, 'B07.jp2')},
175+
'B08': {'href': op.join(url, 'B08.jp2')},
176+
'B8A': {'href': op.join(url, 'B08.jp2')},
177+
'B09': {'href': op.join(url, 'B09.jp2')},
178+
'B10': {'href': op.join(url, 'B10.jp2')},
179+
'B11': {'href': op.join(url, 'B11.jp2')},
180+
'B12': {'href': op.join(url, 'B11.jp2')}
175181
})
176182
#if dt < datetime(2016,12,6):
177183
# del assets['tki']

satstac/sentinel/sentinel-2-l1c.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"url": "https://earth.esa.int/web/guest/home"
3131
},
3232
{
33-
"name": "Synergise",
33+
"name": "Sinergise",
3434
"roles": [
3535
"processor"
3636
],
@@ -233,4 +233,4 @@
233233
"href": "https://sentinel.esa.int/documents/247904/690755/Sentinel_Data_Legal_Notice"
234234
}
235235
]
236-
}
236+
}

0 commit comments

Comments
 (0)