Skip to main content

Median values and percentiles in FISRequest

  • April 17, 2024
  • 6 replies
  • 0 views

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

6 replies

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


  • Known Participant
  • April 17, 2024

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.


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,
)


  • Known Participant
  • April 17, 2024

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

See this example:

docs.sentinel-hub.com
6adc0c17c58b09f5b8063eac7b1d8a910040498a.png

Statistical API

Our powerful Statistical API makes it possible to get various statistics for satellite imagery without having to download images.


  • Known Participant
  • April 17, 2024

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


found it 🙂

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?