Dears,
We’ve been happily using the FIS API for quite a while now to fetch S-2 B04, B08, SCL for single pixels and subsquently visualize the NDVI time-series.
The core function for this is fairly simple, the bounding box is typically 10x10m:
from sentinelhub import FisRequest
def download_l2a_ext(bbox, percent_cc, config, download_cache='D:/Temp', bands=s'B04', 'B08', 'SCL']):
time_interval = ('2017-01-01', '2021-12-30')
eval_script = 'returnr' + ','.join(ns for s in bands]) + ']'
fis_request = FisRequest(
layer='BANDS-S2-L2A',
geometry_list=tbbox],
time=time_interval,
maxcc=percent_cc/100,
resolution='10m',
data_folder=download_cache,
config=config,
custom_url_params={CustomUrlParam.EVALSCRIPT: eval_script},
)
fis_data = fis_request.get_data(save_data=True)
...
This is fairly fast and with a few further steps of local compute (i.e. mask clouds and shadows, compute NDVI, put it in a matplotlib plot) one typically gets the NDVI time series for 5 years within 3-4 seconds.
Since it has been announced that the FIS API will be deprecated we are having a look at the Statisitcal API where the equivalent seems to take one minute or more:
curl -X POST https://services.sentinel-hub.com/api/v1/statistics \
-H 'Authorization: Bearer XXXX' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"input": {
"bounds": {
"bbox": :
786460,
4642960,
786470,
4642970
],
"properties": {
"crs": "http://www.opengis.net/def/crs/EPSG/0/32632"
}
},
"data": :
{
"dataFilter": {},
"type": "sentinel-2-l2a"
}
]
},
"aggregation": {
"timeRange": {
"from": "2017-01-01T00:00:00Z",
"to": "2021-12-31T23:59:59Z"
},
"aggregationInterval": {
"of": "P5D",
"lastIntervalBehavior": "SHORTEN"
},
"resx": "10",
"resy": "10",
"evalscript": "//VERSION=3\nfunction setup() {\n return {\n input: :{\n bands: :\n \"B04\",\n \"B08\",\n \"SCL\",\n \"dataMask\"\n ]\n }],\n output: :\n {\n id: \"data\",\n bands: 3\n },\n {\n id: \"scl\",\n sampleType: \"INT8\",\n bands: 1\n },\n {\n id: \"dataMask\",\n bands: 1\n }]\n };\n}\n\nfunction evaluatePixel(samples) {\n let index = (samples.B08 - samples.B04) / (samples.B08+samples.B04);\n return {\n data: :index, samples.B08, samples.B04],\n dataMask: :samples.dataMask],\n scl: :samples.SCL]\n };\n}\n"
},
"calculations": {
"default": {}
}
}'
Given that our use case if for live interaction with the user such a long wait time is quite a bottleneck.
Two questions:
- Is there anything that seems odd in the Statistical API call above which we should change to improve response time? Could the usage of difference user accounts (payed account for FIS, free account for Statistical API) explain the performance difference.
- If not is it save to continue to build on the FIS API (actually our preffered solution) for the foreseeable future (i.e. at least for one year)?
Thanks and best,