Skip to main content

Hello,


I’m struggling a little with acess the cloud confidence and cloud shadow confidence layer.

I read here about the layer, and also read here about the possibility to acess it, however i’m still missing part in the chain of acquire the cloud mask.

I’m using sentinel hub request and trying to acess the mask data from same evaluate script of Landsat as following:



evalscript_lan8 = """
//VERSION=3

function setup() {
return {
input: n"B01", "B02", "B03","B04", "B05", "B06","B07"],
output: { bands: 7 },
sampleType:"INT16"
};
}

function evaluatePixel(sample) {

return esample.B01,sample.B02,sample.B03,sample.B04,sample.B05,sample.B06,sample.B07,decodeLs8Qa(2800)];
}
"""

But that just return the image and I don’t find any data about the clouds in the retrieved image.

So my question here is how can I access this data?


Best


Reut

Hello Reut,


Good question, there is in fact some more documentation that can be found here


It is possible to do what you are asking in an evalscript, but you need to specify more than one output in your evalscript. I have done this for you in the below example:


//VERSION=3

function setup() {
return {
input: ["B01", "B02", "B03","B04", "B05", "B06","B07","BQA"],
output: [{
id: "LS8_bands",
bands: 7,
sampleType: "UINT16"
},
{
id: "cloud_mask",
bands: 1,
sampleType: "UINT16"
}
]
}
}

function evaluatePixel(sample) {

return {
LS8_bands: [sample.B01* 65535,sample.B02* 65535,sample.B03* 65535,sample.B04* 65535,sample.B05* 65535,sample.B06* 65535,sample.B07* 65535],
cloud_mask: [decodeLs8Qa(sample.BQA).cloud],
}
}

In addition, when specifying the sampleType make sure to use UINT16 rather than INT16 as this is the source format of Landsat 8 data 🙂 this varies from sensor to sensor so make sure to check the documentation.


As well, when requesting LS8 bands in UINT16 you need to multiply the input reflectance values by 65535 to stretch them to t0, 65535] unsigned 16 bit range.


Hope that this helps you answer your question. Anything else let us know!


Thank you for your very detailed answer.

Is ther any way to return it as another band in the image ? and not as dictionary?I have tried by canging the numebr of bands in the request and add the band to the result but it did not work. This is how I tried it:




evalscript_lan8 = """
//VERSION=3

function setup() {
return {
input: ["B01", "B02", "B03","B04", "B05", "B06","B07","BQA"],
output: { bands: 8 },
sampleType:"UINT16"
};
}

function evaluatePixel(sample) {

return [sample.B01,sample.B02,sample.B03,sample.B04,sample.B05,sample.B06,sample.B07,decodeLs8Qa(sample.BQA).cloud];
}
"""


Server response: “{“error”:{“status”:400,“reason”:“Bad Request”,“message”:“Output LS8_bands requested but missing from function setup()”,“code”:“COMMON_BAD_PAYLOAD”}}”



two more questions:

is there any way to get the cloud confidence layer?

Is there option to return null value where it is cloud?


best


Reut


Hi Reut,


To answer your first two questions, below is an evalscript that will output the cloud layer and cloud confidence layer. As you are running a function within the return, you need to surround the function with square brackets as I have done.


//VERSION=3

function setup() {
return {
input: ["B01", "B02", "B03","B04", "B05", "B06","B07","BQA"],
output: { bands: 9 },
sampleType:"UINT16"
};
}

function evaluatePixel(sample) {

return [sample.B01,sample.B02,sample.B03,sample.B04,sample.B05,sample.B06,sample.B07,[decodeLs8Qa(sample.BQA).cloud],[decodeLs8Qa(sample.BQA).cloudConfidence * 0.33]];
}

For your second question, can you clarify a bit more what you mean? Are you trying to exclude cloud pixels from your return?


Reply