Request Builder: 'UNKNOWN' Error

In the request builder I get the pop-up that says “Something went wrong - UNKNOWN”.
It is challenging to find out what is wrong in the script.
The developer tools reflect a HTTP 500 error.

The request is a data fusion request of BYOC PlanetScope data, and has two date ranges. See sh-py below.

Your assistance would be greatly appreciated.

# This is script may only work with sentinelhub.__version__ >= '3.4.0'
from sentinelhub import SentinelHubRequest, DataCollection, MimeType, CRS, BBox, SHConfig, Geometry

# Credentials
config = SHConfig()
config.sh_client_id = '<your client id here>'
config.sh_client_secret = '<your client secret here>'
evalscript = """
//VERSION=3
//NDVI

var viz = new ColorRampVisualizer([
  [-1.0, 0xfb3737],
  [-0.5, 0xf04d1a],
  [-0.2, 0xe15f00],
  [-0.1, 0xd06e00],
  [0.0, 0xbc7c00],
  [0.1, 0xa68700],
  [0.2, 0x8e9000],
  [0.5, 0x749800],
  [1.0, 0x23a312]
])

  
function evaluatePixel(samples, inputData, inputMetadata, customData, outputMetadata) {
  
  let samples_before = samples.before[0]
  let samples_after = samples.after[0]
  let i_before = index(samples_before.Red, samples_before.NIR);
  let i_after = index(samples_after.Red, samples_after.NIR);
  let i_diff = i_after - i_before;
  let val = viz.process(i_diff);
  // val.push(samples_before.dataMask);
  return val
}

function setup() {
  return {
      input: [
          {datasource: "before", bands: ["Red","NIR","dataMask"]},
          {datasource: "after", bands: ["Red","NIR","dataMask"]}
      ],
      output: {
      bands: 4
      }
  }
}
"""
bbox = BBox(bbox=[25.709097, -32.271511, 25.716896, -32.264839], crs=CRS.WGS84)
geometry = Geometry(geometry={"type":"Polygon","coordinates":[[[25.709575,-32.269868],[25.709352,-32.26956],[25.709334,-32.269505],[25.709104,-32.268822],[25.709104,-32.268781],[25.709101,-32.268551],[25.709097,-32.268106],[25.7091,-32.267879],[25.709106,-32.267516],[25.709358,-32.26683],[25.709385,-32.2668],[25.709542,-32.266621],[25.709553,-32.266621],[25.709554,-32.266608],[25.709807,-32.26632],[25.710227,-32.26585],[25.710384,-32.265727],[25.710416,-32.265703],[25.710612,-32.265549],[25.71063,-32.265549],[25.71063,-32.265535],[25.710839,-32.265371],[25.710845,-32.265371],[25.710845,-32.265367],[25.710873,-32.265345],[25.711602,-32.265077],[25.711883,-32.265021],[25.711912,-32.265021],[25.711912,-32.265015],[25.712338,-32.264931],[25.712456,-32.264907],[25.71341,-32.264839],[25.713538,-32.264857],[25.713824,-32.264899],[25.714105,-32.264939],[25.714375,-32.265046],[25.71484,-32.265232],[25.715165,-32.265361],[25.715512,-32.265643],[25.715683,-32.265781],[25.715722,-32.265814],[25.715908,-32.265964],[25.716106,-32.266125],[25.71612,-32.266147],[25.716242,-32.266328],[25.716363,-32.26651],[25.71673,-32.267059],[25.716763,-32.267276],[25.716841,-32.267778],[25.716868,-32.267958],[25.716896,-32.268139],[25.716872,-32.268319],[25.716847,-32.268499],[25.716762,-32.269135],[25.716721,-32.26922],[25.716368,-32.26994],[25.716015,-32.270295],[25.71587,-32.270442],[25.715769,-32.270543],[25.71544,-32.27078],[25.715226,-32.270935],[25.715171,-32.270974],[25.714507,-32.271257],[25.714158,-32.271345],[25.713945,-32.271398],[25.713498,-32.271511],[25.712556,-32.271388],[25.712297,-32.27134],[25.712247,-32.27133],[25.712035,-32.27129],[25.7114,-32.271172],[25.711392,-32.27117],[25.711347,-32.271149],[25.710978,-32.270983],[25.710767,-32.270887],[25.710556,-32.270792],[25.710556,-32.270781],[25.71053,-32.27078],[25.710322,-32.270686],[25.710135,-32.270504],[25.709858,-32.270232],[25.709791,-32.270167],[25.709717,-32.270065],[25.709717,-32.27005],[25.709707,-32.27005],[25.709575,-32.269868]]]}, crs=CRS.WGS84)

request = SentinelHubRequest(
    evalscript=evalscript,
    input_data=[
        SentinelHubRequest.input_data(
            data_collection=DataCollection.define_byoc('025**********************************e07'),          
            identifier=before,
            time_interval=('2023-02-03', '2023-02-03'),          
        ),
       SentinelHubRequest.input_data(
            data_collection=DataCollection.define_byoc('025**********************************e07'),          
            identifier=after,
            time_interval=('2023-04-01', '2023-04-01'),          
        ),
    ],
    responses=[
        SentinelHubRequest.output_response('default', MimeType.PNG),
    ],
    bbox=bbox,
    geometry=geometry,
    size=[512, 517.997],
    config=config
)

response = request.get_data()

Hi @jens.hiestermann ,

It seems to me that there is no need to use data fusion in your case as you’re requesting data from the same BYOC collection. You could use mosaicking ORBIT and preProcessScenes to get the values for “before” and “after”, then you can calculate the difference and return it.

Please take a look at the following request as an example:

curl -X POST https://services.sentinel-hub.com/api/v1/process \
 -H 'Content-Type: application/json' \
 -H 'Authorization: Bearer <token>' \
 -d '{
  "input": {
    "bounds": {
      "bbox": [
        12.44693,
        41.870072,
        12.541001,
        41.917096
      ]
    },
    "data": [
      {
        "dataFilter": {
          "timeRange": {
            "from": "2023-03-01T00:00:00Z",
            "to": "2023-03-31T23:59:59Z"
          }
        },
        "type": "sentinel-2-l2a"
      }
    ]
  },
  "output": {
    "width": 512,
    "height": 343.697,
    "responses": [
      {
        "identifier": "default",
        "format": {
          "type": "image/jpeg"
        }
      }
    ]
  },
  "evalscript": "//VERSION=3\n\nfunction setup() {\n  return {\n    input: [\"B02\"],\n    output: { bands: 1 },\n    mosaicking: \"ORBIT\"\n  };\n}\n\nfunction evaluatePixel(samples) {\n  let after = samples[1].B02;\n  let before = samples[0].B02;\n  return [after - before];\n}\n\nfunction preProcessScenes (collections) {\n    var allowedDates = [\"2023-03-01\", \"2023-03-31\"]; // specify the dates\n    \n    // filter acquisitions\n    collections.scenes.orbits = collections.scenes.orbits.filter(function (orbit) {\n        var orbitDateFrom = orbit.dateFrom.split(\"T\")[0];\n        return allowedDates.includes(orbitDateFrom);\n    })\n\n    // sort acquisitions\n    collections.scenes.orbits.sort(function (s1, s2) {\n            var date1 = new Date(s1.dateFrom);\n            var date2 = new Date(s2.dateFrom);\n            return date1 - date2})\n    return collections\n}"
}'

Thank you @chung.horng, I wasn’t aware that is possible. Let me give it a go.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.