Skip to content

Commit ab9293e

Browse files
authored
Merge pull request #89 from WorldCereal/88-fix-the-point-extraction-merge
Refactored fix
2 parents 595099c + b40ac2e commit ab9293e

File tree

2 files changed

+14
-37
lines changed

2 files changed

+14
-37
lines changed

scripts/inference/cropland_mapping.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
parser.add_argument(
3838
"output_path",
3939
type=Path,
40-
help="Path to folder where to save the resulting NetCDF.",
40+
help="Path to folder where to save the resulting GeoTiff.",
4141
)
4242

4343
args = parser.parse_args()
@@ -73,4 +73,4 @@
7373
product_type=WorldCerealProduct(product),
7474
out_format="GTiff",
7575
)
76-
logger.success("Job finished:\n\t%s", job_results)
76+
logger.success(f"Job finished:\n\t{job_results}")

src/worldcereal/openeo/preprocessing.py

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,8 @@ def worldcereal_preprocessed_inputs_gfmap(
282282
spatial_extent: BoundingBoxExtent,
283283
temporal_extent: TemporalContext,
284284
fetch_type: Optional[FetchType] = FetchType.TILE,
285-
collections: Optional[List[str]] = None,
285+
disable_meteo: bool = False,
286286
) -> DataCube:
287-
if not all(
288-
coll in {"sentinel1", "sentinel2", "cop_dem", "meteo"} for coll in collections
289-
):
290-
raise ValueError(
291-
f"Invalid collection name. Choose from {['sentinel1', 'sentinel2', 'cop_dem', 'meteo']}"
292-
)
293-
cube_list = []
294287
# Extraction of S2 from GFMAP
295288
s2_data = raw_datacube_S2(
296289
connection=connection,
@@ -320,14 +313,9 @@ def worldcereal_preprocessed_inputs_gfmap(
320313
# Cast to uint16
321314
s2_data = s2_data.linear_scale_range(0, 65534, 0, 65534)
322315

323-
# Append the S2 data to the list
324-
if collections is None or "sentinel2" in collections:
325-
cube_list.append(s2_data)
326-
327-
# Decide on the orbit direction from the maximum overlapping area of
328-
# available products.
329-
330316
# Extraction of the S1 data
317+
# Decides on the orbit direction from the maximum overlapping area of
318+
# available products.
331319
s1_data = raw_datacube_S1(
332320
connection=connection,
333321
backend_context=backend_context,
@@ -345,10 +333,6 @@ def worldcereal_preprocessed_inputs_gfmap(
345333
s1_data = mean_compositing(s1_data, period="month")
346334
s1_data = compress_backscatter_uint16(backend_context, s1_data)
347335

348-
# Append the S1 data to the list
349-
if collections is None or "sentinel1" in collections:
350-
cube_list.append(s1_data)
351-
352336
dem_data = raw_datacube_DEM(
353337
connection=connection,
354338
backend_context=backend_context,
@@ -358,23 +342,16 @@ def worldcereal_preprocessed_inputs_gfmap(
358342

359343
dem_data = dem_data.linear_scale_range(0, 65534, 0, 65534)
360344

361-
# Append the copernicus data to the list
362-
if collections is None or "cop_dem" in collections:
363-
cube_list.append(dem_data)
345+
data = s2_data.merge_cubes(s1_data)
346+
data = data.merge_cubes(dem_data)
364347

365-
meteo_data = precomposited_datacube_METEO(
366-
connection=connection,
367-
spatial_extent=spatial_extent,
368-
temporal_extent=temporal_extent,
369-
)
370-
371-
# Append the copernicus data to the list
372-
if collections is None or "meteo" in collections:
373-
cube_list.append(meteo_data)
348+
if not disable_meteo:
349+
meteo_data = precomposited_datacube_METEO(
350+
connection=connection,
351+
spatial_extent=spatial_extent,
352+
temporal_extent=temporal_extent,
353+
)
374354

375-
# Merge the cubes
376-
data = cube_list[0]
377-
for cube in cube_list[1:]:
378-
data = data.merge_cubes(cube)
355+
data = data.merge_cubes(meteo_data)
379356

380357
return data

0 commit comments

Comments
 (0)