To download clipped S2 images with least cloud cover over study area

I am trying to follow the instructions in- Sentinel-2 L2A and scripts from- Examples for S2L2A but these codes do not have an option to download S2 images with an option of cloud cover. I want to download time series S2 image over a bounding box but the images that are used to clip over bb should not have a cloud cover % more than 5. How do I include cloud cover condition before download?

Hi, it is very simple to add a cloud cover filter to your request payload. If you are working with Python you can add a cloud cover % (calculated for the full tile) like this:

request = SentinelHubRequest(
    evalscript=evalscript,
    input_data=[
        SentinelHubRequest.input_data(
            data_collection=DataCollection.SENTINEL2_L2A,          
            time_interval=('2023-05-14', '2023-06-14'),          
            other_args={"dataFilter": {"maxCloudCoverage": 50}}
        )

As you can see it is inserted in other_args. As you also mentioned downloading multiple dates in your request, I would recommend reading this material about how to do this in evalscripts using the preProcessScenes function in our documention.

For example, you can use it to request a time series of values for a single band like in the below example:

//VERSION=3
// Script to extract a time series of Band 5 values using 
// Sentinel 2 Level 2A data and  metadata file.
function setup() {
  return {
    input: [{
      bands: ["B05"],
      units: "DN"
    }],
    output: {
      id: "S2_L2A",
      bands: 1,
      sampleType: SampleType.UINT16
    },
    mosaicking: Mosaicking.ORBIT
  }
}

// The following function is designed to update the number of
// output bands without knowing beforehand how many there are
function updateOutput(outputs, collection) {
    Object.values(outputs).forEach((output) => {
        output.bands = collection.scenes.length;
    });
}

function evaluatePixel(samples) {
  // Precompute an array to contain B05 observations
  var n_observations = samples.length;
  let band_05 = new Array(n_observations).fill(0);
  
  // Fill the array
  samples.forEach((sample, index) => {
    band_05[index] = sample.B05;
  });
                     
  return band_05;
}

Hope that this information helps you out :slight_smile:

Hey, what is the difference between- If mosaicking is ORBIT: and If mosaicking is TILE: taking above codes as an example.

To put it very simply;

TILE will use every acquisition in the time period you requested whereas ORBIT will only select one acquisition from each Orbit. This is explained in more detail here.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.