Skip to main content

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


Hello there,


I am facing the same issue with the Sentinel-2 Global Mosaic best pixel selection script (Sentinel-2 Global Mosaic best pixel selection script | Sentinel Hub custom scripts) as mentioned above.


However, it doesn’t seem to work using the Process API via request builder. I keep getting the following error:
{"error":{"status":400,"reason":"Bad Request","message":"Output default requested but missing from function setup()","code":"COMMON_BAD_PAYLOAD"}}


Do you have any idea of what could be happening? I am running a test with all the defaults from Request Builder just setting the time range to be between 2022-05-01 ~ 2022-09-30.


Hi @boenomarcus ,


In the evalscript it has the following output: "quality_aot", "B11", etc. These outputs need to be set in the Output window when using Requests Builder. Fig 1 is shows how the first output "quality_aoi" is set. You need to use the Add Response button to add all other outputs listed in the setup() function to be able to get the correct response.




Fig 1

Nice, thanks for the support!


The output error was solved, however another one appeared. It follows:


"{"status": 400, "reason": "Bad Request", "message": "Failed to evaluate script!\nevalscript.js:228: ReferenceError: True is not defined\n return True;\n ^\nReferenceError: True is not defined\n at evalscript.js:228:24\n at Array.filter (native)\n at filterByOrbitId (evalscript.js:225:10)\n at evaluatePixel (evalscript.js:148:27)\n at executeForMultipleScenes (:1103:14)\n", "code": "RENDERER_EXCEPTION"}"


It seems to be related to the evalscript itself (I am using the original one from Sentinel-2 Global Mosaic best pixel selection script | Sentinel Hub custom scripts)


Hi @boenomarcus ,


JavaScript booleans are true and false. Please double check the filterByOrbitId function in your script is using them.


Oh yes, I see, thanks, that bug appeared when I asked for the sh-py version under the Request Preview window. I am still getting some errors, though.


When running the sh-py version I just get timed out after a few minutes with the following message.


DownloadFailedException: Failed to download from:
https://services.sentinel-hub.com/api/v1/process
with ReadTimeout:
HTTPSConnectionPool(host='services.sentinel-hub.com', port=443): Read timed out. (read timeout=120.0)
There might be a problem in connection or the server failed to process your request. Please try again.

I also tried to create a workflow with the eo-learn package to get the data as numpy arrays. No errors appear, but then I get the whole unprocessed time series and not the mosaic. I am triple checking the code now, but it seems to be fine.


Hi @boenomarcus ,


Could you perhaps provide the request leading to this timeout issue in the curl format? Since you’re using Requests Builder, you can simply select curl from the drop-down list in the Request Preview window and copy the request. Also, if you could provide the last 4 digit of your Sentinel Hub OAuth client ID that you used to make the request, I can check if there’s anything wrong of your request in our system.


invalid content detected in conversation: 4490 reply: 9

Hi @boenomarcus ,


Thank you for all the info.


I’ve checked your request in our system and the request took almost 6 minutes to be processed, which exceeded the limitation of the snatch processing API. For this kind of long-running requests, you need to use Asynchronous Processing API or Batch Processing API.


Great, I’ll create a new request for a small AOI to give it a go.


Thanks for all your time and patience on this, really appreciate that!


Reply