Skip to content

Commit 5a6aa36

Browse files
committed
update max ndvi
1 parent be0ee29 commit 5a6aa36

File tree

2 files changed

+138
-97
lines changed

2 files changed

+138
-97
lines changed

algorithm_catalog/vito/max_ndvi_composite/openeo_udp/generate.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ def generate() -> dict:
1414
# TODO: use/inject dummy connection instead of concrete one? (See cdse_marketplace_services)
1515
c = openeo.connect("openeofed.dataspace.copernicus.eu")
1616

17-
spatial_extent = Parameter.bounding_box(
18-
name="spatial_extent", default=None, optional=True
19-
)
17+
spatial_extent = Parameter.spatial_extent()
2018
temporal_extent = Parameter.temporal_interval(name="temporal_extent")
2119
schema = {
2220
"type": "string",
@@ -46,9 +44,10 @@ def generate() -> dict:
4644
scl = c.load_collection(
4745
"SENTINEL2_L2A",
4846
temporal_extent=temporal_extent,
47+
spatial_extent=spatial_extent,
4948
bands=["SCL"],
50-
max_cloud_cover=75,
51-
).resample_spatial(projection="EPSG:25832", resolution=10)
49+
max_cloud_cover=max_cloud_cover_param,
50+
)
5251

5352
def scl_to_masks(scl_layer):
5453
to_mask = openeo.processes.any(
@@ -88,8 +87,9 @@ def scl_to_masks(scl_layer):
8887
ndvi_bands = c.load_collection(
8988
"SENTINEL2_L2A",
9089
temporal_extent=temporal_extent,
90+
spatial_extent=spatial_extent,
9191
bands=["B04", "B08"],
92-
max_cloud_cover=75,
92+
max_cloud_cover=max_cloud_cover_param,
9393
)
9494

9595
ndvi_bands = ndvi_bands.mask(cloud_mask)
@@ -108,32 +108,36 @@ def max_ndvi_selection(ndvi):
108108
rgb_bands = c.load_collection(
109109
"SENTINEL2_L2A",
110110
temporal_extent=temporal_extent,
111+
spatial_extent=spatial_extent,
111112
bands=bands_param, # ,"B8A","B11","B12"
112-
max_cloud_cover=75,
113+
max_cloud_cover=max_cloud_cover_param,
113114
)
114115

115-
composite = rgb_bands.mask(combined_mask).max_time().filter_bbox(spatial_extent)
116+
composite = rgb_bands.mask(combined_mask).max_time()
117+
118+
returns = {
119+
"description": "A data cube with the newly computed values.\n\nAll dimensions stay the same, except for the dimensions specified in corresponding parameters. There are three cases how the dimensions can change:\n\n1. The source dimension is the target dimension:\n - The (number of) dimensions remain unchanged as the source dimension is the target dimension.\n - The source dimension properties name and type remain unchanged.\n - The dimension labels, the reference system and the resolution are preserved only if the number of values in the source dimension is equal to the number of values computed by the process. Otherwise, all other dimension properties change as defined in the list below.\n2. The source dimension is not the target dimension. The target dimension exists with a single label only:\n - The number of dimensions decreases by one as the source dimension is 'dropped' and the target dimension is filled with the processed data that originates from the source dimension.\n - The target dimension properties name and type remain unchanged. All other dimension properties change as defined in the list below.\n3. The source dimension is not the target dimension and the latter does not exist:\n - The number of dimensions remain unchanged, but the source dimension is replaced with the target dimension.\n - The target dimension has the specified name and the type other. All other dimension properties are set as defined in the list below.\n\nUnless otherwise stated above, for the given (target) dimension the following applies:\n\n- the number of dimension labels is equal to the number of values computed by the process,\n- the dimension labels are incrementing integers starting from zero,\n- the resolution changes, and\n- the reference system is undefined.",
120+
"schema": {
121+
"type": "object",
122+
"subtype": "datacube"
123+
}
124+
}
116125

117126
return build_process_dict(
118127
process_graph=composite,
119128
process_id="max_ndvi_composite",
120-
summary="Max NDVI composite at 10m resolution.",
129+
summary="Sentinel-2 max NDVI composite at 10m resolution.",
121130
description=(
122-
Path(__file__).parent.parent.parent.parent
123-
/ "algorithm_catalog"
124-
/ "vito"
125-
/ "max_ndvi_composite"
126-
/ "openeo_udp"
127-
/ "max_ndvi_composite_description.md"
131+
Path(__file__).parent / "max_ndvi_composite_description.md"
128132
).read_text(),
129133
parameters=[
130134
spatial_extent,
131135
temporal_extent,
132136
max_cloud_cover_param,
133137
bands_param,
134138
],
135-
returns=None, # TODO
136-
categories=None, # TODO
139+
returns=returns,
140+
categories=["sentinel-2", "composites", "vegetation"]
137141
)
138142

139143

0 commit comments

Comments
 (0)