Skip to main content

Hello community,


I am using this code to fetch the s2l2a data in form of tiff which is working perfectly from the docs.


curl -X POST \
https://services.sentinel-hub.com/api/v1/process \
-H 'Authorization: Bearer <your access token>' \
-F 'request={
"input": {
"bounds": {
"properties": {
"crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-94.04798984527588,
41.7930725281021
],
[
-94.04803276062012,
41.805773608962869
],
[
-94.06738758087158,
41.805901566741308
],
[
-94.06734466552735,
41.7967199475024
],
[
-94.06223773956299,
41.79144072064381
],
[
-94.0504789352417,
41.791376727347969
],
[
-94.05039310455322,
41.7930725281021
],
[
-94.04798984527588,
41.7930725281021
]
]
]
}
},
"data": [
{
"type": "sentinel-2-l2a",
"dataFilter": {
"timeRange": {
"from": "2022-10-01T00:00:00Z",
"to": "2022-10-31T00:00:00Z"
}
},
"processing": {
"harmonizeValues": "true"
}
}
]
},
"output": {
"width": 512,
"height": 512,
"responses": [
{
"identifier": "default",
"format": {
"type": "image/tiff"
}
}
]
}
}' \
-F 'evalscript=//VERSION=3
function setup() {
return{
input: [{
bands: ["B04", "B08"],
units: "REFLECTANCE"
}],
output: {
id: "default",
bands: 1,
sampleType: SampleType.FLOAT32
}
}
}

function evaluatePixel(sample) {
let ndvi = (sample.B08 - sample.B04) / (sample.B08 + sample.B04)
return [ ndvi ]
}'

However some data seems to come with a lot cloud cover in some dates. How can I exclude the clouds inside the area of interest.


Regards,

Edwin.

Hi Edwin, there are plenty of examples of evalscripts on the Custom Scripts Repository, that mask out cloud cover of Sentinel-2 L2A data. For example;



Reply