Hi,
I want to try the HLS product. I have prepared a script to download it, and I actually did it, but I would like to obtain it in a different format, with data etc. This is what I have done:
indices_evalscript = """
//VERSION=3
function setup() {
return {
input: [{
bands:["NIR_Narrow", "Green", "QA"]}],
output:[{
id: "BANDS",
bands: 2,
sampleType: SampleType.FLOAT32
},
{
id: "CLOUD_MASK",
bands: 1,
sampleType: SampleType.UINT8
}]
}
}
function evaluatePixel(sample) {
var cld = (sample.QA >> 1 & 1)
return {
CLOUD_MASK: [cld],
BANDS: [sample.Green, sample.NIR_Narrow]
};
}
"""
add_indices = SentinelHubRequest(
evalscript=indices_evalscript,
input_data=[SentinelHubRequest.input_data(
data_collection=hsl_collection,
time_interval=time_interval,
)],
responses=[
SentinelHubRequest.output_response('BANDS', MimeType.TIFF),
SentinelHubRequest.output_response('CLOUD_MASK', MimeType.TIFF)
],
bbox=roi_bbox,
size=roi_bbox_size,
)
eopatch_clean = add_indices.get_data()[0]
With this I obtained the data but there is no information related to the date.
Instead I wanted something like this:
class AddValidDataMaskTask(EOTask):
def execute(self, eopatch):
#eopatch.mask["VALID_DATA"] = eopatch.mask["dataMask"].astype(bool) & ~(eopatch.mask["CLM"].astype(bool) ) & ~(np.greater(eopatch.mask["CLP"],50))
eopatch.mask["VALID_DATA"] = eopatch.mask["dataMask"].astype(bool) & ~(np.greater(eopatch.mask["CLP"],cld_thr/100*255))
return eopatch
download_task = SentinelHubInputTask(data_collection=DataCollection.SENTINEL2_L1C,
bands=bands,
bands_feature=(FeatureType.DATA, 'BANDS'),
additional_data=[(FeatureType.MASK, 'dataMask'), (FeatureType.MASK, 'CLP')],
resolution=10
)
print('downloading data '+time_interval[0]+'-'+time_interval[1])
input_node = EONode(download_task)
filter_clouds = EONode(AddValidDataMaskTask(),inputs=[input_node])
output_node = EONode(OutputTask("final_eopatch"), inputs=[filter_clouds])
workflow = EOWorkflow([input_node, filter_clouds, output_node])
result = workflow.execute({input_node: {"bbox": roi_bbox, "time_interval": time_interval}})
eopatch_clean = result.outputs['final_eopatch']
or this:
indices_evalscript = """
//VERSION=3
function setup() {
return {
input: ["B17", "B08", "QUALITY_FLAGS"],
output:[{
id: "BANDS",
bands: 2,
sampleType: SampleType.FLOAT32
},
{
id: "CLOUD_MASK",
bands: 1,
sampleType: SampleType.UINT8
}]
}
}
function evaluatePixel(sample) {
let cld = (sample.QUALITY_FLAGS & 134217728);
return {
CLOUD_MASK: [cld],
BANDS: [sample.B17, sample.B08]
};
}
"""
add_indices = SentinelHubEvalscriptTask(
features=[(FeatureType.DATA, "BANDS"),
(FeatureType.MASK, "CLOUD_MASK")],
evalscript=indices_evalscript,
data_collection=DataCollection.SENTINEL3_OLCI,
resolution=300
)
print('downloading data '+time_interval[0]+'-'+time_interval[1])
input_node = EONode(add_indices)
filter_clouds = EONode(AddValidDataMaskTask(),inputs=[input_node])
output_node = EONode(OutputTask("final_eopatch"), inputs=[filter_clouds])
workflow = EOWorkflow([input_node, filter_clouds, output_node])
result = workflow.execute({input_node: {"bbox": roi_bbox, "time_interval": time_interval}})
eopatch_clean = result.outputs['final_eopatch']
Is it possible?