Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
3,012 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env python | ||
|
||
from .s2reader import open, SentinelDataSet, SentinelGranule, BAND_IDS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env python | ||
"""s2reader.cli module.""" | ||
|
||
# from .inspect import main as inspect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env python | ||
"""Command line utility to inspect SAFE files.""" | ||
|
||
import sys | ||
import argparse | ||
import s2reader | ||
import pprint | ||
|
||
|
||
def main(args=None): | ||
"""Print metadata as JSON strings.""" | ||
args = sys.argv[1:] | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("safe_file", type=str, nargs='+') | ||
parser.add_argument("--granules", action="store_true") | ||
parsed = parser.parse_args(args) | ||
|
||
pp = pprint.PrettyPrinter() | ||
for safe_file in parsed.safe_file: | ||
with s2reader.open(safe_file) as safe_dataset: | ||
if parsed.granules: | ||
pp.pprint( | ||
dict( | ||
safe_file=safe_file, | ||
granules=[ | ||
dict( | ||
granule_identifier=granule.granule_identifier, | ||
footprint=str(granule.footprint), | ||
srid=granule.srid, | ||
# cloudmask_polys=str(granule.cloudmask), | ||
# nodata_mask=str(granule.nodata_mask), | ||
cloud_percent=granule.cloud_percent | ||
) | ||
for granule in safe_dataset.granules | ||
] | ||
) | ||
) | ||
else: | ||
pp.pprint( | ||
dict( | ||
safe_file=safe_file, | ||
product_start_time=safe_dataset.product_start_time, | ||
product_stop_time=safe_dataset.product_stop_time, | ||
generation_time=safe_dataset.generation_time, | ||
footprint=str(safe_dataset.footprint), | ||
bounds=str(safe_dataset.footprint.bounds), | ||
granules=len(safe_dataset.granules), | ||
granules_srids=list(set([ | ||
granule.srid | ||
for granule in safe_dataset.granules | ||
])) | ||
) | ||
) | ||
print "\n" | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.