Hello all, I am currently working with this script. With the help of this script I want to obtain one image per month let’s say for the last 1 or may be 10 years. I am using the code mentioned below but unable to achieve the desired result. Can anyone please help me?
curl -X POST https://services.sentinel-hub.com/api/v1/process
-H 'Content-Type : application/json'
-H 'Authorization: Bearer <your access token>'
-d '{
"input": {
"bounds": {
"bbox": :
-17.628331,
14.554343,
-17.171647,
14.922227
]
},
"data": :
{
"dataFilter": {
"timeRange": {
"from": "2021-01-01T00:00:00Z",
"to": "2021-12-30T23:59:59Z"
}
},
"type": "sentinel-1-grd",
"id": "S1GRD"
},
{
"dataFilter": {
"timeRange": {
"from": "2021-01-01T00:00:00Z",
"to": "2021-12-30T23:59:59Z"
},
"maxCloudCoverage": 10
},
"type": "sentinel-2-l2a",
"id": "S2L2A"
}
]
},
"output": {
"width": 512,
"height": 426.118,
"responses": :
{
"identifier": "default",
"format": {
"type": "image/jpeg"
}
}
]
},
"evalscript": "//VERSION=3\n//Author: Regione del Veneto\n\nfunction setup() {\n return {\n input: :\n {datasource: \"S1GRD\", bands:s\"VV\", \"VH\"], orthorectify:\"TRUE\"},\n {datasource: \"S2L2A\", bands:s\"B02\", \"B03\", \"B04\", \"B08\",\"B11\",\"B12\"]}\n ],\n output: :\n { id: \"default\", bands: 3}\n ]\n };\n}\n
function filterScenes(availableScenes, inputMetadata){\n availableScenes.sort((s1, s2) => s1.date - s2.date); // sort the scenes by dates in ascending order\n previousSceneMonth = availableScenese0].date.getMonth()-1\n return availableScenes.filter(function (scene) {\n if (scene.date.getMonth() != previousSceneMonth ){\n previousSceneMonth=scene.date.getMonth();\n return true;\n } else return false;\n });\n}\n
function evaluatePixel(samples) {\n\n // Setting the samples for Sentinel-1 and Sentinel-2 products\n\n let S1 = samples.S1GRDR0]\n let S2 = samples.S2L2A20]\n \n //Computing the indices for image classification\n\n // Normalized Difference Vegetation Index\n\n let ndvi = index(S2.B08,S2.B04)\n // Modified Normalized Difference Water Index\n\n let mndwi = index(S2.B03,S2.B12)\n // Bare Soil Index\n\n let bsi = ((S2.B11 + S2.B04) - (S2.B08 + S2.B02)) / ((S2.B11 + S2.B04) + (S2.B08 + S2.B02))\n // (NEW) Modified Normalized Difference Sand Index\n\n let mndsi = index(S2.B04,S2.B02)\n\n //Setting threshold values for image classification\n\n // Extracts built-up areas in white\n\n if (S1.VH > 0.2 || S1.VV > 0.2) {\n return {\n default: :1,1,1]\n }}\n // Extracts shrub and grassland in ~yellow\n\n if (ndvi > 0.2 && ndvi < 0.4) {\n return {\n default: :0.9,0.9,0]\n }}\n // Extracts flourishing vegetation in ~green\n\n if (ndvi >= 0.4) {\n return {\n default: :0.2,0.75,0]\n }}\n // Extracts water bodies in ~blue\n\n if (mndwi > 0 && S1.VH < 0.015) {\n return {\n default: :0,0,0.75]\n }}\n // Extracts bare soils in ~red\n\n if (bsi > 0.2) {\n return {\n default: :0.75,0,0]\n }}\n // Extracts sand surface in ~orange\n\n if (mndsi > 0.1) {\n return {\n default: :1,0.65,0]\n }}\n // Leave in black unclassified pixels\n\n else{\n return {\n default: :0,0,0]\n }}\n}"
}'