Median values and percentiles in FISRequest

Currently, the FISRequest returns mean, min, max, stdev. Can it be extended to return median or better still user-specified percentile?

Not at the moment, but we have this in plans for the next iteration of the FIS API, planned to come in a few months.

2 Likes

Hi @gmilcinski - is this now available via the statistical API? meaning, can we request median or even define custom statistical function?

Indeed, Statistical API does allow for definition of percentiles, including median. Custom statististical function is currently not supported.

See this example:

How can I implement it in Python API?
For example here:

sd = ‘2022-05-10’ # start date
ed = ‘2022-05-11’ # end date
sn2_ndvi_request = SentinelHubStatistical(
aggregation=SentinelHubStatistical.aggregation(
evalscript=sn2_ndvi_evalscript,
time_interval=(sd, ed),
aggregation_interval=“P1D”,
resolution=(0.0001, 0.0001),
),
input_data=[SentinelHubStatistical.input_data(DataCollection.SENTINEL2_L2A)],
geometry=poly,
config=config,
)

found it :slight_smile:

sd = '2022-05-10' # start date
ed = '2022-05-11' # end date


calcs = {"ndvi": {"statistics": {"default":{"percentiles":{"k":[50]}}}}}


sn2_ndvi_request = SentinelHubStatistical(
                                        aggregation=SentinelHubStatistical.aggregation(
                                        evalscript=sn2_ndvi_evalscript,
                                        time_interval=(sd, ed),
                                        aggregation_interval="P1D",
                                        resolution=(0.0001, 0.0001),
                                        ),
                                        input_data=[SentinelHubStatistical.input_data(DataCollection.SENTINEL2_L2A)],
                                        geometry=poly,
                                        config=config,
                                        calculations=calcs
                                            )

sn2_ndvi_stats = sn2_ndvi_request.get_data()[0]

It is possible to drop the “min” and “max”? would that reduce the number of PU?

No, Statistical API response always contains “min” and “max” values. However, this does not impact your PU consumption.

Hi, I would like to report that percentiles is not working with the statistical api. Only ‘histogram’ and ‘stats’ fields are returned, there is no ‘percentile’ field returned like shown in the documentation.. This is my calculations dictionary being passed. As mentioned, only histogram statistics are successfully returned. No percentiles data are returned at all.

calculations = { "default": { "histograms": { "default": { "bins": ["0.0", "1.0", "2.0", "3.0", "4.0", "5.0", ] } }, "statistics": { "default": { "percentiles": { "k": [ "25", "50", "75" ] } } } } }

Please can you check this? Note: I tried passing both strings and numbers in “k”.

Thanks.

After more investigation, the “percentiles” dictionary containing the data returned from the API randomly appears and then disappears under the “stats” dictionary for results returned from the API if stats results are NaN or null. This does not explain why it does not appear at all with some data types. Seems like a bug.