How to visualize a gray-scale single band using Evalscript

Hello folks,

I’ve been trying to visualize a specific band of a satellite imagery by modifying the evalscript in configuration utility. For example, I acquired just the ‘VV’ band of a SAR image. There are two templates (base products) provided there: (1) VV - linear visualization from 0 to 0.5, and (2) VV - decibel visualization from -20 dB to 0 dB. Both the methods seem to stretch the VV band quite simply. However, I could only see a black background image when I check the ‘preview’. I tried to stretch it more using VV*4 or using a higher scaler. It didn’t work. I was also thinking if this is because the preview needs a three-band 8-bit image to visualize, such as a standard PNG. But it still did not work when I tried ‘return [VV, VV, VV]’. I was expecting it give me a gray-scale visualization but the resulting preview was still a black background.

My eventual goal is to request such gray-scale image as a PNG and show it in my web map based on Google Map Javascript API. I’m confused because the EO Browser does show a gray-scale VV bands when that visualization seems to reply on a very simple ‘return [VV]’. It just does not work when I set the same (or a similar) script in my configuration.

Any comments will be appreciated!

Hi @yichen.yang ,

Does the following request meet your goal? If not, please provide your request which returns a black image and we can investigate it.

curl -X POST https://services.sentinel-hub.com/api/v1/process \
 -H 'Content-Type: application/json' \
 -H 'Authorization: Bearer ' \
 -d '{
  "input": {
    "bounds": {
      "bbox": [
        12.44693,
        41.870072,
        12.541001,
        41.917096
      ]
    },
    "data": [
      {
        "dataFilter": {
          "timeRange": {
            "from": "2023-07-23T00:00:00Z",
            "to": "2023-08-23T23:59:59Z"
          }
        },
        "type": "sentinel-1-grd"
      }
    ]
  },
  "output": {
    "width": 512,
    "height": 343.697,
    "responses": [
      {
        "identifier": "default",
        "format": {
          "type": "image/png"
        }
      }
    ]
  },
  "evalscript": "//VERSION=3\n\nfunction setup() {\n  return {\n    input: [\"VV\"],\n    output: { bands: 1 }\n  };\n}\n\nfunction evaluatePixel(sample) {\n  return [sample.VV];\n}"
}'

Hi @chung.horng,

Thank you for looking into this. I’ve been using the OCG service. The final goal is to construct the image urls dynamically in html. But I would like to test the evalscript to be concatenated with the url. I tried to use the ‘set product’ in configuration utility and used the following script:
image
Then in the preview model of that SAR layer, I saw black images. However, I checked the utility functions and found a simple solution:
image
This showed a single band in gray scale successfully.

Thanks a lot!

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