Hi,
According to the eo-learn example, you will need to define a EO workflow and then execute it as shown below:
add_data = SentinelHubInputTask(
bands_feature=(FeatureType.DATA, "BANDS"),
bands=bands_name,
resolution=10,
maxcc=0.8,
time_difference=datetime.timedelta(minutes=120),
data_collection=DataCollection.SENTINEL2_L2A,
additional_data=[(FeatureType.MASK, "dataMask", "IS_DATA"), (FeatureType.MASK, "CLM"), (FeatureType.DATA, "CLP")],
max_threads=5,
config=config
)
save = SaveTask(EOPATCH_FOLDER, overwrite_permission=OverwritePermission.OVERWRITE_PATCH)
workflow_nodes = linearly_connect_tasks(
add_data,
save
)
workflow = EOWorkflow(workflow_nodes)
%%time
# Time interval for the SH request
time_interval = ["2021-10-16", "2021-10-31"]
# Define additional parameters of the workflow
input_node = workflow_nodes[0]
save_node = workflow_nodes[-1]
execution_args = []
for idx, bbox in enumerate([bbox]):
execution_args.append(
{
input_node: {"bbox": bbox, "time_interval": time_interval},
save_node: {"eopatch_folder": f"eopatch_{idx}"},
}
)
# Execute the workflow
executor = EOExecutor(workflow, execution_args, save_logs=True)
executor.run(workers=1)
executor.make_report()
failed_ids = executor.get_failed_executions()
if failed_ids:
raise RuntimeError(
f"Execution failed EOPatches with IDs:\n{failed_ids}\n"
f"For more info check report at {executor.get_report_path()}"
)
Note that when using SentinelHubInputTask
you have less control on the request. With time_difference
set to datetime.timedelta(minutes=120)
, you will be requesting all available acquisitions during the specified time_interval
. To request acquisitions you’re interested in only, I’d suggest using SentinelHubEvalscriptTask and applying preProcessScenes function to filter the data.
Hi,
What if i remove the time_difference
set to datetime.timedelta(minutes=120)
parameter while using the SentinelHubInputTask function??
The time_difference
argument is used to filter out consecutive acquisition whose timestamp is too close to the previous one. For example, using your AOI with a time range from 2021-10-01 to 2021-10-31 without setting a time_difference
will get the following timestamps:
[datetime.datetime(2021, 10, 1, 5, 40, 48),
datetime.datetime(2021, 10, 1, 5, 40, 51),
datetime.datetime(2021, 10, 6, 5, 40, 53),
datetime.datetime(2021, 10, 6, 5, 40, 57),
datetime.datetime(2021, 10, 11, 5, 40, 49),
datetime.datetime(2021, 10, 11, 5, 40, 53),
datetime.datetime(2021, 10, 16, 5, 40, 54),
datetime.datetime(2021, 10, 16, 5, 40, 57),
datetime.datetime(2021, 10, 21, 5, 40, 50),
datetime.datetime(2021, 10, 21, 5, 40, 53),
datetime.datetime(2021, 10, 26, 5, 40, 54),
datetime.datetime(2021, 10, 26, 5, 40, 57),
datetime.datetime(2021, 10, 31, 5, 40, 50),
datetime.datetime(2021, 10, 31, 5, 40, 53)]
As you can see there are 2 timestamps close to each other on 1st, 6th, 11th, 16th, 21st, 26th, and 31st. They are the same data being projected to different tiles (Fig 1) and you may not need them both. In this case we apply time_difference=datetime.timedelta(minutes=120)
to get all available acquisitions we need without requesting duplicated data. Below shows the timestamps when time_difference
is applied.
[datetime.datetime(2021, 10, 1, 5, 40, 48),
datetime.datetime(2021, 10, 6, 5, 40, 53),
datetime.datetime(2021, 10, 11, 5, 40, 49),
datetime.datetime(2021, 10, 16, 5, 40, 54),
datetime.datetime(2021, 10, 21, 5, 40, 50),
datetime.datetime(2021, 10, 26, 5, 40, 54),
datetime.datetime(2021, 10, 31, 5, 40, 50)]
Fig 1
also, what if i have multiple bounding boxes stored in a list. how do i cater to all the bounding boxes using the same workflow?
Please have a look at the example script I provided above. You can create a list of execution_args
with your bounding box list. The EOExecutor
will help you run all of them.