-
Notifications
You must be signed in to change notification settings - Fork 42
/
R_example.py
57 lines (41 loc) · 1.32 KB
/
R_example.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
import logging
import time
import openeo
from openeo.auth.auth_bearer import BearerAuth
logging.basicConfig(level=logging.INFO)
GEE_DRIVER_URL = "https://r-server.openeo.org/"
OUTPUT_FILE = "/tmp/openeo_R_output.png"
user = "test"
password = "test"
#connect with GEE backend
#session = openeo.session("nobody", GEE_DRIVER_URL)
# TODO: update examples
con = openeo.connect(GEE_DRIVER_URL, auth_type=BearerAuth, auth_options={"username": user, "password": password})
#Test Connection
#print(con.list_processes())
#print(con.list_collections())
#print(con.describe_collection("sentinel2_subset"))
# Test Capabilities
#cap = con.capabilities
#print(cap.version())
#print(cap.list_features())
#print(cap.currency())
#print(cap.list_plans())
# Test Processes
processes = con.get_processes()
pg = processes.get_collection(name="sentinel2_subset")
print(pg.to_json())
pg = processes.filter_bbox(pg, west=16.138916, south=-19, east=16.524124, north=-18.9825)
print(pg.to_json())
pg = processes.filter_daterange(pg, extent=["2017-01-01T00:00:00Z", "2017-01-31T23:59:59Z"])
print(pg.to_json())
pg = processes.ndvi(pg, nir="B4", red="B8A")
print(pg.to_json())
pg = processes.min_time(pg)
print(pg.to_json())
# Test Job
job = pg.create_job()
print(job.job_id)
print(job.start_job())
print (job.describe_job())
job.download_results("/tmp/testfile")