I have seen some comments in the forum that for a setup that iterates polygon by polygon and gets the images by acquisition dates, there is not a lot of difference between SentinelHubRequest and WcsRequest (e.g. this post).
But I want to compare the time, complexity, advantages, and disadvantages of both.
I know there is a possibility to first search for dates using catalog and then make individual requests but this notebook skips that.
Here is what I came up with for a simple request trying to modify the notebook above, but I am having a hard time making it work:
evalscript = """
//VERSION=3
function setup() {
return {
input: [{
datasource: "S2L2A",
bands: ["B03"]
}
],
output: [
{
id: "G",
bands: 1,
sampleType: SampleType.FLOAT32
},
],
mosaicking: "ORBIT"
};
}
function preProcessScenes (collections) {
var s2dates = collections.S2L2A.scenes.orbits.map(function (orbit) {
return orbit.dateFrom.split("T")[0];
});
collections.S2L2A.scenes.orbits = collections.S2L2A.scenes.orbits.filter(function (orbit) {
var orbitDateFrom = orbit.dateFrom.split("T")[0];
return s2dates.includes(orbitDateFrom);
});
return collections;
}
function updateOutput(outputs, collections) {
n_bands = collections.S2L2A.scenes.orbits.length;
outputs.G.bands = n_bands;
}
function evaluatePixel(samples) {
var b3_band = [];
var s2_data = samples.S2L2A;
// Add Sentinel-2 data to the band array
for (i=0; i<s2_data.length; i++){
b3_band.push(s2_data[i].B03);
}
return {
G: b3_band
};
}
"""
Set up AOI
rome = [12.44693, 41.870072, 12.541001, 41.917096]
rome_bbox = BBox(bbox=rome, crs=CRS.WGS84)
Time interval
time_interval = (‘2020-10-27’, ‘2021-01-14’)
request = SentinelHubRequest(
evalscript=evalscript,
input_data=[
SentinelHubRequest.input_data(
data_collection=DataCollection.SENTINEL2_L1C,
time_interval=time_interval,
other_args = {"id":"S2L2A"}
),
],
responses=[
SentinelHubRequest.output_response('G', MimeType.TIFF)
],
bbox=BBox(polygons_gdf.iloc[1,1],polygons_gdf.crs),
config=config,
data_folder="./data_fusion/"
)
all_common_data = request.get_data(save_data=False)