Creating mosaic in eo-learn


I created mosaic for each patch using np.median(['TRUE-COLOR-S2-L1C'], axis=0).squeeze()
But since it is numpy array, I cannot add it as data_timeless to EOPatch. I wonder how I can do this.

Thank you in advance for your help.

This works for me:

eopatch.data_timeless['test'] = np.median(['BANDS'], axis=0).squeeze()

#['BANDS'].shape is (n_timestamps, height, width, n_bands), n_bands>1
# eopatch.data_timeless['test'].shape is (height, width, n_bands)

Please check that the dimension of your data_timeless feature is 3. In case you only have single band in your data, then the squeeze() you are using is removing that dimension, and you might have ended up with a numpy array with shape (height, width).

Otherwise, please provide more details (e.g. paste the error you get).


1 Like

I wanted to add that squeeze() can act a bit too sharply sometimes. Usually you have a good idea which axis you want to squeeze, so I would suggest using squeeze(axis=0) or some other axis, whenever you use it.

Dear @batic,

Thank you for your help - The main idea is to prepare the RGB mosaic out of the time series so there is not 1D feature, and your script worked very well :slight_smile:

Kind regards,