I have tried to add this to my evalscript but get errors:
ndvi_evalscript= """
//VERSION=3
function setup() {
return {
input: [
{
bands: [
"B04",
"B08",
"dataMask"
]
}
],
output: [
{
id: "ndvi",
bands: 1
},
{
id: "dataMask",
bands: 1
}
]
}
}
function evaluatePixel(samples) {
return {
let NDVI=index(samples.B08, samples.B04)
let NDVI_UNDER_04 = (NDVI < 0.40) ? 1 : 0;
ndvi: [NDVI,NDVI_UNDER_04],
dataMask: [samples.dataMask]
};
}
"""
#run statistics like in the documentation
yearly_time_interval = '2020-01-01', '2020-12-31'
aggregation = SentinelHubStatistical.aggregation(
evalscript=ndvi_evalscript,
time_interval=yearly_time_interval,
aggregation_interval='P1D',
resolution=(10, 10)
)
input_data = SentinelHubStatistical.input_data(
DataCollection.SENTINEL2_L2A
)
histogram_calculations = {
"ndvi": {
"histograms": {
"default": {
"nBins": 20,
"lowEdge": -1.0,
"highEdge": 1.0
}
}
}
}
ndvi_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)),
calculations=histogram_calculations,
config=config
)
ndvi_requests.append(request)
%%time
download_requests = [ndvi_request.download_list[0] for ndvi_request in ndvi_requests]
client = SentinelHubStatisticalDownloadClient(config=config)
ndvi_stats = client.download(download_requests)
len(ndvi_stats)
That part runs but when I print the ndvi_stats can see error of bad request/execution error:
[{'data': [{'interval': {'from': '2020-01-04T00:00:00Z',
'to': '2020-01-05T00:00:00Z'},
'error': {'type': 'EXECUTION_ERROR'}},
{'interval': {'from': '2020-01-09T00:00:00Z', 'to': '2020-01-10T00:00:00Z'},
'error': {'type': 'EXECUTION_ERROR'}},
{'interval': {'from': '2020-01-14T00:00:00Z', 'to': '2020-01-15T00:00:00Z'},
'error': {'type': 'EXECUTION_ERROR'}},
{'interval': {'from': '2020-01-19T00:00:00Z', 'to': '2020-01-20T00:00:00Z'},
'error': {'type': 'EXECUTION_ERROR'}},
{'interval': {'from': '2020-01-24T00:00:00Z', 'to': '2020-01-25T00:00:00Z'},
'error': {'type': 'BAD_REQUEST'}},
.....
When I run this withou the NDVI_UNDER etc. it works just like in the tutorial.
Do you see my mistake?
thanks a lot 