Hi,
I prepared the evalscript
and processRequest
script for Batch processing to calculate the mean of the Sentinel-1 VV and VH. I am not sure if the script is correct or not?! Is there any way to test to be sure? Or maybe you can check it out yourself?!
Kind regards,
Behzad
evalscript
evalscript = """
//VERSION=3
function setup() {
return {
input: ["VV", "VH","dataMask"],
output: { id:"default", bands: 2,sampleType: SampleType.FLOAT32},
mosaicking: Mosaicking.ORBIT
}
}
// Function to calculate the average of the bands
function calculateAverage(samples) {
var sum = 0;
var nValid = 0;
for (let i = 0; i < samples.length; i++) {
var sample = samples[i];
if (sample.dataMask != 0) {
nValid++;
sum += sample;
}
}
return sum / nValid;
}
function evaluatePixel(samples) {
var vv_mean = calculateAverage(samples.VV)
var vh_mean = calculateAverage(samples.VH)
return [vv_mean,vh_mean]
}
"""
processRequest
payload = {
"processRequest": {
"input": {
"bounds": {
"bbox": [
8.44,
41.31,
9.66,
43.1
],
"properties": {
"crs": "http://www.opengis.net/def/crs/EPSG/0/32635"
}
},
"data": [
{
"type": "S1GRD",
"dataFilter": {
"timeRange": {
"from": "2017-11-15T00:00:00Z",
"to": "2017-11-15T23:00:00Z"
},
"acquisitionMode": "IW",
"polarization": "DV",
"orbitDirection ": "ASCENDING"
},
"processing": {
"backCoeff": "GAMMA0_ELLIPSOID",
"orthorectify": "true"
}
}
]
},
"output": {
"width": 1000,
"height": 1000,
"responses": [{
"identifier": "default",
"format": {
"type": "image/tiff"
}
}]
},
"evalscript": evalscript
},
"tilingGrid": {
"id": 0,
"resolution": 10.0
},
"bucketName": "<MyBucket>",
"description": "VH/VV mean ASCENDING "
}