Evalscript for S1 vegetation index

Hi guys!
Im trying to obtain vegetation index for Sentinel 1… However, request came with “EXECUTION-ERROR”
Bellow the script Im trying to request:

yearly_time_interval = '2020-01-01', '2020-01-31'
evalscript = """
//VERSION=3

function evaluatePixel(samples) {
    let val = [2*samples.VV/samplesVV- samples.VH];
    return [val, samples.dataMask];
}

function setup() {
  return {
    input: [{
      bands: [
        "VV",
        "VH",
        "dataMask"
      ]
    }],
    output: {
      bands: 2
    }
  }
}
"""


aggregation = SentinelHubStatistical.aggregation(
    evalscript=evalscript,
    time_interval=yearly_time_interval,
    aggregation_interval='P12D',
    resolution=(10, 10)
)

input_data = SentinelHubStatistical.input_data(
    DataCollection.SENTINEL1_IW
)
vv_requests = []
for geo_shape in polygons_gdf.geometry.values:
    request = SentinelHubStatistical(
        aggregation=aggregation,
        input_data=[input_data], 
        geometry=Geometry(geo_shape, crs=CRS(polygons_gdf.crs)),
        config=config
    )
    vv_requests.append(request)


Further:
%%time

download_requests = [vv_request.download_list[0] for vv_request in vv_requests]
    
client = SentinelHubStatisticalDownloadClient(config=config)

vv_stats = client.download(download_requests)

len(vv_stats)

Does anyone know how to fix it?

dataMask needs to be in it’s own output. See example.

//VERSION=3

function evaluatePixel(samples) {
   let val = [2*samples.VV/samplesVV- samples.VH];
   return {
            'values': [val], 
            'dataMask': [samples.dataMask]
          }
}

function setup() {
  return {
    input: [{
      bands: [ "VV", "VH", "dataMask" ]
    }],
    output: [
      {
        id: "values",
        bands: 1,
        sampleType: "FLOAT32"
      },
      {
        id: "dataMask",
        bands: 1
      }]
  }
}
1 Like

Hi @batic thanks for you answer, but the error persists, even with your evalscript.

[{‘data’: [{‘interval’: {‘from’: ‘2020-01-01T00:00:00Z’,
‘to’: ‘2020-01-13T00:00:00Z’},
‘error’: {‘type’: ‘EXECUTION_ERROR’}},
{‘interval’: {‘from’: ‘2020-01-13T00:00:00Z’, ‘to’: ‘2020-01-25T00:00:00Z’},
‘error’: {‘type’: ‘EXECUTION_ERROR’}}]

After re-formatting your original post: there is a typo in your evalscript:

[2*samples.VV/samplesVV- samples.VH];

The second samplesVV is missing a dot (should be samples.VV)

1 Like

My mistake, sorry!
It is perfectly working now =)
Thank you very much!