Multiple requests in a for loop

Hi – I am trying to download several small area multi-temporal Sentinel-2 subsets using sentinelhub.py. At the moment this is the workflow I’m using:

  1. Open a Shapefile with several polygons
  2. Define an evalscript to create NDVI and GCI
  3. Define two SentinelHubEvalscriptTasks and a SavaeTask and Output Task
  4. Loop through each polygon to create an eopatch_dir name, bounding box, then run linearly_connect_tasks, EOWorkflow, and execute.

That is giving me an error:
400 Client Error: Bad Request for url: https://services.sentinel-hub.com/api/v1/process
Server response: “{“status”: 400, “reason”: “Bad Request”, “message”: “Failed to evaluate script!\nundefined:1076: evaluatePixel must return an array\n throw "evaluatePixel must return an array";\n ^\n”, “code”: “RENDERER_EXCEPTION”}”

I am able to run this without the for loop using a single polygon so I expect I’m missing a fundamental concept required for submitting several requests in a for loop. Is there an example I can look at or specific documentation someone can direct me to?

Hi @nedhorning ,

The error message indicates the evaluatePixel function in your Evalscript is not returning an array, which is not accepted by our APIs. Please make sure the evaluatePixel function is always returning an array in your script, e.g., [NaN] or [ndvi] or [sample.B04, sample.B03, sample.B02].

Thank you Chung, I appreciate your feedback. I found the problem. I didn’t realize that the key in the return statement of the evaluatePixel() function had to be the same as the id key in the setup() function. Once I corrected that the error went away.