forked from climatefarmers/vegetation-health
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwekeo_downloader.py
99 lines (60 loc) · 1.7 KB
/
wekeo_downloader.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python
# coding: utf-8
# In[ ]:
##aprrove terms and conditions of use at least once with your token @wekeo.eu sign-in
##@: https://www.wekeo.eu/docs/harmonised-data-access-api
## curl --request PUT --header 'accept: application/json' --header 'authorization: <access_token>' --data 'accepted=true' https://wekeo-broker.apps.mercator.dpi.wekeo.eu/databroker/termsaccepted/Copernicus_General_License
# In[12]:
from hda import Client
import os
# In[13]:
def get_parent_dir(directory):
return os.path.dirname(directory)
current_dirs_parent = get_parent_dir(os.getcwd())
# In[14]:
##ad out directory where to download the files
outdir = '/home/neuwirth/work/GIS/Projekte/Fernerkundung/0_Daten/Europe/Sentinel2/'
#add wekeo accountinfo to textfile
lines = ['url: https://wekeo-broker.apps.mercator.dpi.wekeo.eu/databroker',
'user: XXX',
'password: XXX']
with open(current_dirs_parent+'/.hdarc', 'w') as f:
f.write('\n'.join(lines))
# In[15]:
c = Client(url="https://wekeo-broker.apps.mercator.dpi.wekeo.eu/databroker",debug=True)
# In[16]:
os.chdir(outdir)
# In[20]:
query = {
"datasetId": "EO:ESA:DAT:SENTINEL-2:MSI",
"boundingBoxValues": [
{
"name": "bbox",
"bbox": [
-8.612802734375,
38.138437871376254,
-8.118850107255466,
38.62992694505725
]
}
],
"dateRangeSelectValues": [
{
"name": "position",
"start": "2020-08-01T00:00:00.000Z",
"end": "2021-02-01T00:00:00.000Z"
}
],
"stringChoiceValues": [
{
"name": "processingLevel",
"value": "LEVEL2A"
}
]
}
matches = c.search(query)
# In[21]:
os.getcwd()
# In[ ]:
#print(matches)
matches.download()