Thank you, William, for the quick reply. The script I am using worked in the past. In this instance, it appears as if I could access several images before it got to day 180. Here is the code I’m using:
shapefile = '/home/nedhorning/Abe/Paddocks/PaddocksUTM18N_21August2024_Aggregated.shp'
eopatch_path = "/home/nedhorning/Abe/Paddocks2023FarmAggregate21August2024/"
epsg = "EPSG:32618"
time_interval = ("2023-04-25", "2023-11-15") # time interval of downloaded data
resolution = 30 # resolution of the request (in metres)
vt_bbox = [624360, 4732860 , 777150, 4991340] # Coordinates for VT [xmin, ymin, xmax, ymax]
expansion_dist = 100 # Distance in meters to expand each side of a bounding rectangle
# time difference parameter (minimum allowed time difference; if two observations are closer than this,
# they will be mosaicked into one observation)
time_difference = datetime.timedelta(hours=12)
gdf = gpd.read_file(shapefile)
bands_evalscript = """
//VERSION=3
function setup() {
return {
input: [{
bands: ["CoastalAerosol", "Blue", "Green", "Red", "NIR_Narrow", "SWIR1", "SWIR2", "Cirrus",\
"QA", "dataMask"],
units: "DN"
}],
output: [{
id: "ms_data",
bands: 8,
sampleType: SampleType.UINT16
}, {
id: "quality_bands",
bands: 2,
sampleType: SampleType.INT16
}]
}
}
function evaluatePixel(sample) {
bandsDN = [sample.CoastalAerosol, sample.Blue, sample.Green, sample.Red, sample.NIR_Narrow,
sample.SWIR1, sample.SWIR2, sample.Cirrus];
qualityBands = [sample.QA, sample.dataMask]
return {
ms_data: bandsDN,
quality_bands: qualityBands
}
}
"""
# this will add all Sentinel multispectral bands as DN (int) not reflectance (float)
add_ms_bands = SentinelHubEvalscriptTask(
features=[(FeatureType.DATA, "ms_data")],
evalscript=bands_evalscript,
data_collection=DataCollection.HARMONIZED_LANDSAT_SENTINEL,
resolution=resolution,
time_difference=time_difference,
config=config,
max_threads=3
)
# this will add all Sentinel pixel quality bands as DN (int) not reflectance (float)
add_quality_bands = SentinelHubEvalscriptTask(
features=[(FeatureType.DATA, "quality_bands")],
evalscript=bands_evalscript,
data_collection=DataCollection.HARMONIZED_LANDSAT_SENTINEL,
resolution=resolution,
time_difference=time_difference,
config=config,
max_threads=3
)
farm_list = []
for i in range(len(gdf)):
print(f"\rProcessing aggregate {i+1} of {len(gdf)}", end='', flush=True)
# Get the current polygon
polygon = gdf.loc[i, "geometry"]
# Extract the polygon's coordinates
x_coords, y_coords = polygon.exterior.coords.xy
# Get the filename by concatenating the "farm" and "name" attributes
farm = gdf.loc[i, 'Farm']
farm_list.append(farm)
xmin = int(min(x_coords) - expansion_dist)
xmax = int(max(x_coords) + expansion_dist)
ymin = int(min(y_coords) - expansion_dist)
ymax = int(max(y_coords) + expansion_dist)
# region of interest
roi_coordinates = adjust_bounding_box(xmin, ymin, xmax, ymax)
roi_bbox = BBox(roi_coordinates, crs=CRS(epsg))
save = SaveTask(eopatch_path + "numpyHLS", overwrite_permission=2, compress_level=0)
output_task = OutputTask(farm)
#workflow_nodes = linearly_connect_tasks(add_indices, add_ms_bands, save, output_task)
workflow_nodes = linearly_connect_tasks(add_ms_bands, add_quality_bands, save, output_task)
workflow = EOWorkflow(workflow_nodes)
result = workflow.execute(
{
workflow_nodes[0]: {"bbox": roi_bbox, "time_interval": time_interval},
workflow_nodes[-2]: {"eopatch_folder": farm},
}
)