-
Notifications
You must be signed in to change notification settings - Fork 21
/
query_stac.py
38 lines (30 loc) · 1.01 KB
/
query_stac.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#
# Imports
#
import sys
import json
import sliderule
from utils import parse_command_line
from sliderule import earthdata
###############################################################################
# MAIN
###############################################################################
if __name__ == '__main__':
# Defaults
cfg = {
"dataset": "HLS",
"region": "examples/grandmesa.geojson",
"time_start": "2021-01-01T00:00:00Z",
"time_end": "2022-01-01T23:59:59Z",
"display_all": False
}
# Command line parameters
parse_command_line(sys.argv, cfg)
# Region of interest
polygon = sliderule.toregion(cfg["region"])["poly"]
# Query CMR for list of resources
geojson = earthdata.stac(short_name=cfg["dataset"], polygon=polygon, time_start=cfg["time_start"], time_end=cfg["time_end"])
# Display Results
print("Returned {} features".format(geojson["context"]["returned"]))
if cfg["display_all"]:
print(json.dumps(geojson, indent=2))