-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathgee_uc1_pol.py
61 lines (42 loc) · 2.13 KB
/
gee_uc1_pol.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
import openeo
from openeo.internal.graph_building import PGNode
# Connect to backend via basic authentication
con = openeo.connect("https://earthengine.openeo.org/v1.0")
con.authenticate_basic()
datacube = con.load_collection("COPERNICUS/S1_GRD",
spatial_extent={"west": 16.06, "south": 48.1, "east": 16.65, "north": 48.31},
temporal_extent=["2017-03-01", "2017-04-01"],
bands=["VV", "VH"])
mean = datacube.mean_time()
vh = PGNode("array_element", arguments={"data": {"from_parameter": "data"}, "label": "VH"})
vv = PGNode("array_element", arguments={"data": {"from_parameter": "data"}, "label": "VV"})
reducer = PGNode("subtract", arguments={"x": {"from_node": vh}, "y": {"from_node": vv}})
datacube = mean.reduce_dimension(dimension="bands", reducer=reducer)
# B
blue = datacube.add_dimension(name="bands", label="B", type="bands")
lin_scale = PGNode("linear_scale_range", arguments={"x": {"from_parameter": "x"},
"inputMin": -5, "inputMax": 0, "outputMin": 0, "outputMax": 255})
blue = blue.apply(lin_scale)
# G
green = mean.filter_bands(["VH"])
green = green.rename_labels(dimension="bands", target=["G"])
lin_scale = PGNode("linear_scale_range", arguments={"x": {"from_parameter": "x"},
"inputMin": -26, "inputMax": -11, "outputMin": 0, "outputMax": 255})
green = green.apply(lin_scale)
# R
red = mean.filter_bands(["VV"])
red = red.rename_labels(dimension="bands", target=["R"])
lin_scale = PGNode("linear_scale_range", arguments={"x": {"from_parameter": "x"},
"inputMin": -20, "inputMax": -5, "outputMin": 0, "outputMax": 255})
red = red.apply(lin_scale)
# RGB
datacube = red.merge(green).merge(blue)
datacube = datacube.save_result(format="PNG", options={"red": "R", "green": "G", "blue": "B"})
print(datacube.to_json())
# Send Job to backend
job = datacube.create_job()
res = job.start_and_wait().download_results()
for key, val in res.items():
print(key)
zrdz = list(res.keys())[0].name
print("test")