For mosaicked image, get tile metadata per pixel

  • 26 April 2024
  • 6 replies

Hi, would it be possible to receive, when mosaicking an image within a certain BBox, per pixel metadata about the tile (date of aquisition, tile code) that is underlying that pixel?

Looking for a solution using either the Sentinel-hub package (SentinelHubRequest) or eo-learn package.


6 replies

This translates in the Evalscript, which you define for the mosaicking algorithm. In that script you can define a new “output band” and write in it whatever you are interested in, i.e. “day of the year” or similar.

I suggest you check how this is done in Sentinel-2 Global Mosaic:

Sentinel-Hub custom scripts

Sentinel-2 Global Mosaic best pixel selection script

A repository of custom scripts that can be used with Sentinel-Hub services.

If I am not mistaken, valid_obs output is what you are looking for.

Thanks Grega, I’ll check this out!

Hi Grega, the “day of year” is not as straight forward as I expected. Especially for the mosaicking algorithm, as it seems the date might only be available for non-mosaicked images between start- and end date?

Could you provide a more hands-on example for the questions? Thanks so much.

Hi @52thijs,

I am not sure I understand the question “date might only be available for non-mosaicked images between start- and end date”.

That said, find below the sample code, starting with “max ndvi” script and converting it so that it returns two bands:

  • band 1 = max NDVI value over the time period
  • band 2 = day of the year of the pixel with max NDVI value
//VERSION=3 (auto-converted from 1)

function setup() {
  return {
    input: [{
      bands: [
    output: { 
      bands: 2,
      sampleType: "FLOAT32" 
    mosaicking: "ORBIT"

function calculateDayOfYear(currentDate)
  var now = new Date();
  var start = new Date(currentDate.getFullYear(), 0, 0);
  var diff = currentDate - start;
  var oneDay = 1000 * 60 * 60 * 24;
  var day = Math.floor(diff / oneDay);
  return day;

function calcNDVI(sample) {
  var denom = sample.B04+sample.B08;
  return ((denom!=0) ? (sample.B08-sample.B04) / denom : 0.0);
function evaluatePixel(samples, scenes, inputMetadata, customData, outputMetadata) {  
  var max = 0;
  var days = 0;
  for (var i=0;i<samples.length;i++) {
      var ndvi = calcNDVI(samples[i]);
      if (ndvi > max)
        max = ndvi; 
        days = calculateDayOfYear(scenes[i].date)
  return [max, days];

Hi Grega,

Thanks, this already more clear. I’m especially looking for the dates if the ‘mosaickingOrder’ of leastCC is used (e.g. via a SentinelHubRequest) as with this example extracting the least cloudy mosaick between to dates.

Is there a way to adapt the evalscript to return the date of the used pixel in this leastCC mosaick, e.g. doing the mosaicking within the evalscript?


evalscript = """
    function setup() {
        return {
            input: [{
                bands: ["B02","B03","B04","B05","B06","B07","B08","B8A","B11","B12", "CLP"],
                units: "DN"
            output: {
                bands: 10,
                sampleType: "INT16"

    function evaluatePixel(sample) {
        if (sample.CLP > 0.4) {
                return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        return [sample.B02, sample.B03, sample.B04, sample.B05, sample.B06,
                sample.B07, sample.B08, sample.B8A, sample.B11, sample.B12];
request = SentinelHubRequest(
            time_interval=(time_window[0], time_window[1]),
        SentinelHubRequest.output_response('default', MimeType.TIFF)

No, this is not possible.
When you are using SIMPLE mosaicking order, we blend the data, i.e. fusing pixels on the border of scenes, to get visually best image.
If you want to have deterministic results, you have to use ORBIT (or, if really really relevant, but we would not advise it, TILE) and then make mosaic based on cloud cover data. Results will also be much better as SIMPLE mosaicking is done based on cloud-coverage data on scene level, so there might still be quite some clouds remaining.


Planet Monitoring

© 2024 Planet Labs PBC. All rights reserved.
| Privacy Policy | California Privacy Notice | California Do Not Sell
Your Privacy Choices | Cookie Notice | Terms of Use