Make S2 global mosaic script work with Evalscript V3

I am currently, separately, using the S2 global mosaic hub, and accessing S2 imagery through the Evalscript V3 API. In some cases, I need to use my own compositing algorithm to develop monthly mosaics, so I use Evalscript.

In some cases, the S2 global mosaic algorithm suites my needs more than perfectly! It works so well in cloudy tropical regions. I’d love to be able to access the S2 global mosaic outputs through the Evalscript API.

I see that the script for generating the mosaic is available on the custom scripts repository here (https://custom-scripts.sentinel-hub.com/sentinel-2/s2gm) but with a note that it needs V2 to run.

I’ve been trying to convert the script to V3 for awhile, but I can’t seem to get it to work. If I run the V2 script through V3, I either get “Output default requested but missing from function setup()” or “EvaluatePixel must return an array” as errors.

I’ve been reading through the V3 documentation (https://docs.sentinel-hub.com/api/latest/evalscript/v3/) and can’t seem to figure out what needs to change. I’m happy to implement the changes if anyone can give me a direction!

Hi @john.brandt,

perhaps the messaging is not the best.
The script is already in Evalscript V3.
What the “Sentinel Hub API v.2” refers to is that you cannot run it through our OGC APIs (WCS, WMS, etc) but rather through our “core” API (process API). This is due to the fact that it has several outputs, whereas OGC can only retreive one file.

You might try it with Request Builder

That said, I have not run the script myself and with its complexity it might be that there are issues, unrelated to the above.

In case it is not working with process API, can you let us know which area you are looking into and which time period and we will try to do it ourselves as well?

Make sure to also check Batch API, so that you can run this on larger scale!

Edit: Seems to work with the process API! Going to work on making it a bit simpler to be faster, but I love the STC algorithm

1 Like