Merging datacubes

Hi all,

When merging a datacube, the documentation says:

Data cubes with the dimensions x, y and t have the same dimension labels in x,y and t. There are two options:

  • Keep the overlapping values separately in the merged data cube: An overlap resolver is not needed, but for each data cube you need to add a new dimension using add_dimension. The new dimensions must be equal, except that the labels for the new dimensions must differ by name. The merged data cube has the same dimensions and labels as the original data cubes, plus the dimension added with add_dimension, which has the two dimension labels after the merge.

When not using an overlap resolver I get:
java.lang.UnsupportedOperationException: The operator: null is not supported when merging cubes. Supported operators are: Set(subtract, min, divide, or, max, xor, multiply, add, sum, and, product).

When using an overlap resolver, I get:
java.lang.IllegalArgumentException: Merging cubes with an overlap resolver is only supported when band counts are the same. I got: 4 and 1.

Right now I use:

dc_wo_m: DataCube = dc_wo_resampled.add_dimension("source", "JRC", type="other")
dc_optical_m: DataCube = dc_optical.add_dimension("source", "S2_L1C", type="other")
dc_merged: DataCube = dc_optical_m.merge_cubes(dc_wo_m, overlap_resolver=processes.max)

to merge the datacubes. I also tried overlap_resolver=None. The datacubes have different bands with the same xy resolution using resample_cube_spatial. Any ideas?

Could it be that you merge the optical cube with dims (x,y,t,bands) with a cube with only (x,y)?
It seems that this is not supported yet indeed.
Masking the optical cube with the water mask would be supported, but I guess that’s not what you’re after?

Please let me know how urgent this is, I believe we can add it.

This is the water occurrence dataset that I am looking to merge with optical (S2_L1C).
interesting that the occurrence band changes into 1 when downloading.

The context for this merge is that I want to use the water occurrence dataset in my UDF, so I am trying to merge that dataset into the optical data. I need this dataset for the waterwatch algorithm.