Skip to main content

Get Tiff with SCL specific values only

  • April 26, 2024
  • 2 replies
  • 290 views

Hi everyone, I’m trying to acoomplish the following:
I would like to get a tiff, with only one band with two possible values 0 or 1, being 1 when SCL layer has the values 8,9 and 10 and being 0 when SCL band has other values
in order to accomplish that I did the following, but it doesn,t seem to work.

request:
{
“input”: {
“bounds”: {
“properties”: {
“crs”: “http://www.opengis.net/def/crs/OGC/1.3/CRS84
},
“geometry”: {
“type”: “Polygon”,
“coordinates”: [
[
[-63.41364922869325,-31.93362350846114],
[-63.41371005284875,-31.94145368039172],
[-63.40655276580051,-31.94048123194298],
[-63.40669107412236,-31.93356798316035],
[-63.41364922869325,-31.93362350846114]
]
]
}
},
“data”: [
{
“type”: “S2L2A”,
“dataFilter”: {
“timeRange”: {
“from”: “2019-02-23T00:00:00Z”,
“to”: “2019-02-26T00:00:00Z”
}
}
}
]
},
“output”: {
“width”: 512,
“height”: 512,
“responses”: [
{
“identifier”: “default”,
“format”: {
“type”: “image/tiff”
}
}
]
}
}

EVAL SCRIPT:
//VERSION=3
function setup() {
return{
input: [ “SCL”],
output: {bands: 1}
}
}

function evaluatePixel(sample) {
if ([8, 9, 10].includes(sample.SCL) ){
return [1]
} else{
return [0]
}
}

I have to clarify that the selected area and date has been chosen because they are partially cloudy, so I was specting to get some values in 1 following the shape of the clouds and the rest in 0.

Can anyone give me a hand on this…sugestions…
thanks in advance.

2 replies

yeap sorry, I found the issue and updated the original post, but failed to inform it was solved.
and yes, now it works properly

sorry again and thanks


Hi,

your request seems to work nicely for me. I get:

Cordoba.tiff (3.1 KB)

To me it seems that the shape of the cloud roughly corresponds to what I can see in the true color ima ge:Sentinel Hub EO Browser

Is the result not in line with what you expect?