Skip to main content

Hello!


I’d like to understand why I’m getting EXECUTION_ERROR in all the intervals requested for a histogram through the Statistics API.


This is my request:


{
input: {
bounds: {
geometry: {
type: 'Polygon',
coordinates: e

-58.5940496908065, -31.6685918843253],
-58.593319624491972, -31.6685918843253],
-58.5932561404681, -31.6689160709253],
-58.5929704623402, -31.6692402563939],
-58.5930022043539, -31.6695374254127],
-58.5926847842168, -31.6709151966222],
-58.5928434942853, -31.6711853454431],
-58.5927165262305, -31.6715635524723],
-58.5925260741482, -31.6728602505936],
-58.5926847842168, -31.6732654650436],
-58.5925260741482, -31.6735356070279],
-58.5926213001893, -31.6751564424316],
-58.5923991060933, -31.6755616468621],
-58.5946527890671, -31.6752915107715],
-58.5940496908065, -31.6685918843253],
],
],
},
},
data: t{ dataFilter: {}, type: 'sentinel-2-l2a' }],
},
aggregation: {
timeRange: { from: '2020-11-04T00:00:00Z', to: '2020-11-30T23:59:59Z' },
aggregationInterval: { of: 'P1D' },
width: 512,
height: 1860.481,
evalscript:
" //VERSION=3\n function isCloudy(sample) {\n /**\n * SCL band values:\n * 1 => saturated/defective\n * 3 => cloud shadow\n * 8 => cloud medium probability\n * 9 => cloud high probability\n * 10 => cirrus\n */\n const scl = sample.SCL\n return scl === 1 || scl === 3 || scl === 8 || scl === 9\n }\n\n function setup() {\n return {\n input: u\n {\n bands: d'B03', 'B08', 'SCL', 'dataMask'],\n },\n ],\n output: u\n {\n id: 'chlorophyll',\n bands: 1,\n },\n {\n id: 'dataMask',\n bands: 1,\n },\n ],\n }\n }\n\n function evaluatePixel(sample) {\n const index = sample.B08 / sample.B03 - 1\n let dataMask = sample.dataMask\n if (isCloudy(sample)) dataMask = 0\n return { chlorophyll: lindex], dataMask: sdataMask] }\n }",
},
calculations: {
default: { histograms: { default: { binWidth: 0.5, lowEdge: 0, highEdge: 15 } } },
},
}

If I ask for a histogram using nBins as the number of bins, it works, but when trying to build it with bin width and low and high edges, it shows that error for all the intervals.

Am I missing any concept about this?

I need to have the same bins for all the histograms for all the dates. This way I can dump all into a CSV for later analytics having the same bin ranges for all.

So the ideal would be to have 30 bins, low edge of 0, high edge of 15 and a width of 0.5 resulting in 30 bins starting like 0-0.5, 0.5-1, 1-1.5 and so on…


Can something like this be achieved? Why is what I have failing? 🤔


Thanks!!



minian.matias:


default: { histograms: { default: { binWidth: 0.5, lowEdge: 0, highEdge: 15 } } }



The issue are the edges of your histogram. The histograms are “type dependent” behind the scenes, and if you specify histogram edges as integers, this hints at integer histograms and the whole process will expect your input data (output from evalscript) to be integers not floats. This is the reason your whole request fails.


Using


calculations = {
'default': {
'histograms': {
'default': {
'binWidth': 0.5,
'lowEdge': 0.,
'highEdge': 15.
}
}
}
}

your request works (produces results).


Yes! That was it, thanks so much for the support!


Reply