Duplicate band when merging cubes

Hi.
I’m trying to run the following notebook:

When merging the cubes (cell where sentinel_2_and_1 is created), I get the following error:
ValueError: Duplicate band Band(name=‘B02’, common_name=‘blue’, wavelength_um=None, aliases=None, gsd=None)

Any hint why this happens? Changing the name before also lead to the same error.

Thanks

you get this error on this line?

sentinel_2_and_1 = sigma0_sentinel_1_cube_reduced_10m.merge_cubes(boa_sentinel_2_cube_reduced)

what do you get if you do

print(sigma0_sentinel_1_cube_reduced_10m.metadata.band_names)
print(boa_sentinel_2_cube_reduced.metadata.band_names)

Hi @stefaan.lippens

I get this:
[‘B02’, ‘B01’]
[‘B02’, ‘B03’, ‘B04’, ‘B08’]

So… how can I rename the bands? 0:)

Thanks a lot

hmm that’s strange: sigma0_sentinel_1_cube_reduced_10m is Sentinel1 data, so it should not have bands like B02 or B01.
I think there is something wrong with the construction of sigma0_sentinel_1_cube_reduced_10m on your side. Are you executing that notebook as-is, or are you fiddling/experimenting with some bits?

The only change that I did was to the name of the collection and the lists (which I don’t think to be the source of the problem):

collectionS2      = "boa_sentinel_2"
spatial_extent  = {"crs": "PROJCRS[\"Azimuthal_Equidistant\",BASEGEOGCRS[\"WGS 84\",DATUM[\"World Geodetic System 1984\",ELLIPSOID[\"WGS 84\",6378137,298.257223563,LENGTHUNIT[\"metre\",1]]],PRIMEM[\"Greenwich\",0,ANGLEUNIT[\"degree\",0.0174532925199433]],ID[\"EPSG\",4326]],CONVERSION[\"Modified Azimuthal Equidistant\",METHOD[\"Modified Azimuthal Equidistant\",ID[\"EPSG\",9832]],PARAMETER[\"Latitude of natural origin\",53,ANGLEUNIT[\"degree\",0.0174532925199433],ID[\"EPSG\",8801]],PARAMETER[\"Longitude of natural origin\",24,ANGLEUNIT[\"degree\",0.0174532925199433],ID[\"EPSG\",8802]],PARAMETER[\"False easting\",5837287.81977,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8806]],PARAMETER[\"False northing\",2121415.69617,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8807]]],CS[Cartesian,2],AXIS[\"easting\",east,ORDER[1],LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]]],AXIS[\"northing\",north,ORDER[2],LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]]]]",
                   "east": aoi_bounds[0],
                   "north": aoi_bounds[1],
                   "south": aoi_bounds[3],
                   "west": aoi_bounds[2]}
temporal_extent = ["2018-05-01", "2018-09-01"]
bandsS2           = ["B02","B03","B04","B08"]

boa_sentinel_2_cube = conn.load_collection(
    collection_id   = collectionS2,
    spatial_extent  = spatial_extent,
    temporal_extent = temporal_extent,
    bands = bandsS2
    )

boa_sentinel_2_cube_reduced = boa_sentinel_2_cube.reduce_dimension(dimension="t",reducer=median)

collectionS1      = "gamma0_sentinel_1_dv" 
spatial_extent  = {"crs": "PROJCRS[\"Azimuthal_Equidistant\",BASEGEOGCRS[\"WGS 84\",DATUM[\"World Geodetic System 1984\",ELLIPSOID[\"WGS 84\",6378137,298.257223563,LENGTHUNIT[\"metre\",1]]],PRIMEM[\"Greenwich\",0,ANGLEUNIT[\"degree\",0.0174532925199433]],ID[\"EPSG\",4326]],CONVERSION[\"Modified Azimuthal Equidistant\",METHOD[\"Modified Azimuthal Equidistant\",ID[\"EPSG\",9832]],PARAMETER[\"Latitude of natural origin\",53,ANGLEUNIT[\"degree\",0.0174532925199433],ID[\"EPSG\",8801]],PARAMETER[\"Longitude of natural origin\",24,ANGLEUNIT[\"degree\",0.0174532925199433],ID[\"EPSG\",8802]],PARAMETER[\"False easting\",5837287.81977,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8806]],PARAMETER[\"False northing\",2121415.69617,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8807]]],CS[Cartesian,2],AXIS[\"easting\",east,ORDER[1],LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]]],AXIS[\"northing\",north,ORDER[2],LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]]]]",
                   "east": aoi_bounds[0],
                   "north": aoi_bounds[1],
                   "south": aoi_bounds[3],
                   "west": aoi_bounds[2]}
temporal_extent = ["2018-05-01", "2018-09-01"]
bandsS1           = ["vh","vv"]

sigma0_sentinel_1_cube = conn.load_collection(
    collection_id   = collectionS1,
    spatial_extent  = spatial_extent,
    temporal_extent = temporal_extent,
    bands = bandsS1
    )

sigma0_sentinel_1_cube_reduced = sigma0_sentinel_1_cube.reduce_dimension(dimension="t",reducer=median)
print(sigma0_sentinel_1_cube.metadata.band_names)

sigma0_sentinel_1_cube_reduced_10m = sigma0_sentinel_1_cube_reduced.resample_cube_spatial(target=boa_sentinel_2_cube_reduced)

@benjamin.schumacher can EODC help out with these collections?

Sorry for the delayed reply. We will have a look at this as soon as we can.

Hi there - I strongly suspect this mapping of dimension names to occur somewhere in our opendatacube setup. However, similar to Job queued - #5 by lukas.weidenholzer I’ll have to pass on this one, I’m not familiar enough with how this was setup to help out - possibly @sean.hoyal could have a look when he’s back from holiday on 03.01.2023?

1 Like

On the note about the B0 band naming convention, this was corrected on 19/12/2022, so they do appear as expected (VV/VH). I’m not sure if there is anything else I am able to help with here directly, unless I have missed something!

Hi again,
Thanks for your feedback @lukas.weidenholzer and @sean.hoyal .

I tried once again to run once again the script, and I get a new error that was not happening before, when I try to build the cube (I guess it’s a problem with load collection :
[500] 500: ‘email’ (ref: e656cc54-b39a-4edc-93f5-2630ed994a1c).

I don’t know if I should create a new thread for this one, but since it’s the same code I keep it here:

collectionS2      = "boa_sentinel_2"
spatial_extent  = {"crs": "PROJCRS[\"Azimuthal_Equidistant\",BASEGEOGCRS[\"WGS 84\",DATUM[\"World Geodetic System 1984\",ELLIPSOID[\"WGS 84\",6378137,298.257223563,LENGTHUNIT[\"metre\",1]]],PRIMEM[\"Greenwich\",0,ANGLEUNIT[\"degree\",0.0174532925199433]],ID[\"EPSG\",4326]],CONVERSION[\"Modified Azimuthal Equidistant\",METHOD[\"Modified Azimuthal Equidistant\",ID[\"EPSG\",9832]],PARAMETER[\"Latitude of natural origin\",53,ANGLEUNIT[\"degree\",0.0174532925199433],ID[\"EPSG\",8801]],PARAMETER[\"Longitude of natural origin\",24,ANGLEUNIT[\"degree\",0.0174532925199433],ID[\"EPSG\",8802]],PARAMETER[\"False easting\",5837287.81977,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8806]],PARAMETER[\"False northing\",2121415.69617,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8807]]],CS[Cartesian,2],AXIS[\"easting\",east,ORDER[1],LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]]],AXIS[\"northing\",north,ORDER[2],LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]]]]",
                   "east": aoi_bounds[0],
                   "north": aoi_bounds[1],
                   "south": aoi_bounds[3],
                   "west": aoi_bounds[2]}
temporal_extent = ["2018-05-01", "2018-09-01"]
bandsS2           = ["B02","B03","B04","B08"]

boa_sentinel_2_cube = conn.load_collection(
    collection_id   = collectionS2,
    spatial_extent  = spatial_extent,
    temporal_extent = temporal_extent,
    bands = bandsS2
    )