Evalscript in EO browser to display only a specific tile

Is it possible in a simple evalscript that I can use in EO browser (not with API request) to specify a particular tile to be sampled - let say for a the tile 34TCN only and not the orbit

I imagined that it will be specified with preProcessScenes, but until now I couldn’t make it work

This is an undocumented feature as it does not work for all collections consistently.
That said, for e.g. Sentinel-2 L2A data you should be able to enter something along the lines of:

function preProcessScenes(collections) {
collections.scenes.tiles = collections.scenes.tiles.filter(
(tile) => tile.productId === "S2A_MSIL2A_20200915T101031_N0214_R022_T33TVM_20200915T130644");
return collections;

Note that you need to use TILE mosaicking for this to work.

Thank you, Grega, for the swift reply!

I tried the following code, but still i get the whole orbit and not the tile:


function setup() {
  return {
    input: [{
      bands: ["B02", "dataMask"],
      units: ["REFLECTANCE", "DN"]
    output: {
      bands: 1,
      sampleType: "UINT16",
      mosaiking: "TILE", 
      scale: 10,
      interpolation: "NEAREST"

function preProcessScenes(collections) {
collections.scenes.tiles = collections.scenes.tiles.filter(
(tile) => tile.productId === "S2A_MSIL2A_20200915T101031_N0214_R022_T33TVM_20200915T130644")
return collections

function evaluatePixel(samples) {
  return [samples.dataMask === 1 ? 20 * samples.B02 * 10000 : NaN]

Can you share the link to the EO Browser, where you’ve tried this?


The mosaicking is set wrong in your case - there is a typo, and in the wrong place.

Check this example

1 Like

Thank you for your valuable input!

Your script works with that specific tile and if I change the date on the top with the date chooser widget , I no longer have a tile plotted. What I was trying to achieve is to fetch all images from specific tileFrame ID and not to be tied to a specific file name. As very soon I will be trying to retrieve a set of images for this tile in a range of dates.
I am quite new with the scripting, and probably I need more guidance than an experienced person as you are would expect. Sorry for that :innocent:

Not sure what you mean by “tileFrame”.
You can try to filter by part of the product ID string:

1 Like

Ah, yes! This is what I mean by TileID/tileFRAME

When I ask for date 2020-09-09 (it shows in the widget there is an image available) nothing is visualized - I guess, this is somehow related to the mosaicking order to most resent by default. How can I access this other image? Let say I want to make average for a period of time and be able to sample all of the acquisitions.

By “the widget” you are referring to the calendar? This one is displaying all available imagery in the current window, and does not take into account the filtering in the custom script.

For the “average” - take a look at this script how the “max NDVI” is calculated. You can do similar with average.

1 Like

Yes, the calendar I was describing. So first one have the date and the spatial window of the browser, and then we have the prepocessing settings to narrow down the search, right?

I tried to alter your code to include several tiles in this manner:

function preProcessScenes(collections) {
  const TILElist = [

  const regexPattern = new RegExp(TILElist.join("|"));

  collections.scenes.tiles = collections.scenes.tiles.filter(
    (tile) => regexPattern.test(tile.productId)
  return collections;

However overlapping zones are empty, and moreover, when I change the zoom level, some tiles disappear.
I have the mosaicking set to TILE, , but how to set the return code in order to see a complete coverage (for all the tiles in focus, plus overlapping zones) for a particular date?

If working for multi-temporal output, how do one defines dataMask in order to display area covered by both images if two are targeted in a collection?

Neither samples[1].dataMask, nor samples[0].dataMask will be presenting the area covered by both of them.

I think I figured this out by myself.
I had to multiply both masks :innocent: