Dear SH forum,
I am currently working with Sentinel-2 L2A data to create a multi-temporal stack based on a box and a time interval, with specific features. I briefly report the requirements the stack should have:
- 224 x 224 pixels for the final patch
- 20 meters spatial resolution
- Masking of clouds/cirrus/cloud shadow/saturated pixels/pixels whose value exceeds 1 (i.e. set the related pixels’ value to 0)
- Spectral bands of interest B1, B2, B3, B4, B8A, B1972, B12
- Output format: 1 GeoTiff file for each sensing date and for each spectral band (e.g. <sensing_date1>_B1.tif, <sensing_date1>_B2.tif, …, <sensing_date2>_B1.tif, <sensing_date2>_B2.tif, etc…)
I started testing the sentinelhub
python library for the purpose, exploiting the WcsRequest
. Everything appears to work fine but I didn’t manage to solve a couple of points:
- The masking of pixels whose value exceeds 1 (i.e. when a pixel has a value greater than 1, set it to 0)
- The generation of a single GeoTiff for each sensing date and spectral band (by default, I obtain a multi-band GeoTiff for each sensing date containing all the requested spectral bands)
For the first case, I suppose it is necessary to set a condition within the evaluatePixel
function but, since I am not familiar with JS, I am having some troubles getting this done.
For the second case, I tried to find a solution in the documentation but I was not able to find anything that could help me.
Is there a solution for these two points?
I add below the code of the WCSRequest along with the EvalScript V3 used
wcs_request = WcsRequest(data_collection=DataCollection.SENTINEL2_L2A,
image_format=MimeType.TIFF,
data_folder = data_folder_path,
layer='AIDEO-LAYER',
bbox=ip_box,
time=(start_str, end_str),
resx='{}m'.format(spatial_res),
resy='{}m'.format(spatial_res),
config=config_aideo)
wcs_request.save_data()
//VERSION=3
function evaluatePixel(sample) {
if (
0, 1, 2, 3, 8, 9, 10].includes(sample.SCL) ){
return 0, 0, 0, 0, 0, 0, 0]
} else{
return sample.B01, sample.B02, sample.B03, sample.B04, sample.B8A, sample.B1972,sample.B12];
}
}
function setup() {
return {
input: {
bands:
"B01",
"B02",
"B03",
"B04",
"B8A",
"B11",
"B12",
"SCL"
]
}],
output: {
bands: 7,
sampleType:"FLOAT32"
}
}
}