Stats API band order not preserved

Hi Sentinel Hub team,

I’ve been working with using both the stats api and processing api in the same workflow.

One major challenge is that the evalscripts need to be different for each (e.g. when using processing api via eo-learn), which is inconvenient.

However, an additional challenge is that the stats api doesn’t preserve the order of the bands as requested, while the processing api does.
Take evalscripts which return the following:
bands: [“B02”, “B03”, “B04”, “B05”, “B06”, “B07”, “B08”, “B8A”, “B11” ,“B12”, “CLP”]

The processing API, via eo-learn, will return a numpy array with the bands in this order.
However, the stats api will return json objects where the bands are in this order:
[“B11”, “B12”, “B02”, “B03”, “B04”, “CLP”, “B05”, “B06”, “B07”, “B08”, “B8A”]
(I’m not sure of the order - its not alphabetical…)

Just to clarify, this is the case in the raw response.content, not just the decoded json (returns a dict), therefore the reordering is happening on the Sentinel Hub side.
It would make sense if the band order in stats api requests was preserved from the evalscript for consistency.

Kind regards
Sam

Hi @sbphd ,

thank you for this feedback and for the suggestion. Your observation is correct, different ordering happens on the server side, which is indeed a bit inconvenient. We will check if this can be changed as suggested in one of the future releases.
In the meanwhile, I would suggest that you always define custom names for output bands when using Statistical api (see how this is done for the first output in this example). The band names are repeated in the response, so you know exactly which statistics belong to which output band.

Kind regards,
Anja