V3 Transition for Sentinel 2 L2A level

Hello everyone!

Today I found that all my layers configured in v1 and v2 have converted to v3. Any layers that used Sentinel 2 L2A level of processing become unable for visualization.

Does anybody know how to configure Sentinel 2 L2A data?
Below is the non-working script after automatic conversion.

let minVal = 0.0;
let maxVal = 0.4;

let viz = new DefaultVisualizer(minVal, maxVal);

function evaluatePixel(samples) {
let val = [samples.B04, samples.B03, samples.B01];
val = viz.processList(val);
val.push(samples.dataMask);
return val;
}

function setup() {
return {
input: [{
bands: [
“B01”,
“B03”,
“B04”,
“dataMask”
]
}],
output: {
bands: 4
}
}
}

Hello!
I found that your script uses incorrect quotation marks around bands in the function setup(); you are using ”, while " should be used. Additionally, as the script is V3, it needs to have //VERSION=3 on top.
If you replace the quotation marks in your script with " and add //VERSION=3, you should find it working.
When you say “I found that all my layers configured in v1 and v2 have converted to v3”, do you mean you converted them yourself? Did you use the convert button to do so? It would be helpful for us to understand how the mistake happened.

//VERSION=3
let minVal = 0.0;
let maxVal = 0.4;
let viz = new DefaultVisualizer(minVal, maxVal);

function evaluatePixel(samples) {
    let val = [samples.B04, samples.B03, samples.B01];
    val = viz.processList(val);
    val.push(samples.dataMask);
    return val;
}

function setup() {
    return {
        input: [{
            bands: [
                "B01",
                "B03",
                "B04",
                "dataMask"
            ]
        }],
        output: {
            bands: 4
        }
    }
}

I hope the scripts work now. If you encounter any issues, don’t hesitate to follow up.

Best,
Monja

1 Like