Catalog API features dates vs. Statistical API aggregation discrepancy

Hi,

We’re trying to combine sentinel-2-l2a polygon images from Process API with statistical data from Statistical API.
In order to get dates when images are available in Process API, we first issue a Catalog API request to get dates when features are available for a polygon. This works without any issues.

The problem we’re facing is that we’re not getting any data if we define aggregation timeRange on the same dates we are getting features/images for.

In fact I’m providing the Catalog API and Statistical API request/response examples below with the same date ranges in order to make the problem clearer:

Catalog API

Request:

{
"datetime":"2022-05-01T00:00:00Z/2022-05-25T00:00:00Z",
"collections":["sentinel-2-l2a"],"limit":100,"next":null,
"intersects":{"type":"Polygon","coordinates":[[[18.394922043052787,45.538507554149675],[18.404536366875135,45.52966827663937],[18.40702579000876,45.530991250113885],[18.397153939654004,45.53971006956863],[18.394922043052787,45.538507554149675]]]},
 "fields": {
    "include":["id", "properties.datetime", "properties.eo:cloud_cover", "properties.platform", "properties.constellation"],
    "exclude": ["type", "geometry", "bbox", "links", "assets"] 
}}

Response:

{
    "type": "FeatureCollection",
    "features": [
        {
            "id": "S2B_MSIL2A_20220524T094029_N0400_R036_T33TYL_20220524T113845",
            "properties": {
                "datetime": "2022-05-24T09:48:02Z",
                "constellation": "sentinel-2",
                "eo:cloud_cover": 12.9,
                "platform": "sentinel-2b"
            }
        },
        {
            "id": "S2A_MSIL2A_20220522T095041_N0400_R079_T33TYL_20220522T142504",
            "properties": {
                "datetime": "2022-05-22T09:58:05Z",
                "constellation": "sentinel-2",
                "eo:cloud_cover": 45.0,
                "platform": "sentinel-2a"
            }
        },
        {
            "id": "S2A_MSIL2A_20220519T094041_N0400_R036_T33TYL_20220519T140711",
            "properties": {
                "datetime": "2022-05-19T09:48:08Z",
                "constellation": "sentinel-2",
                "eo:cloud_cover": 0.0,
                "platform": "sentinel-2a"
            }
        },
        {
            "id": "S2B_MSIL2A_20220517T095029_N0400_R079_T33TYL_20220517T124459",
            "properties": {
                "datetime": "2022-05-17T09:57:58Z",
                "constellation": "sentinel-2",
                "eo:cloud_cover": 63.49,
                "platform": "sentinel-2b"
            }
        },
        {
            "id": "S2B_MSIL2A_20220514T094029_N0400_R036_T33TYL_20220514T113831",
            "properties": {
                "datetime": "2022-05-14T09:48:01Z",
                "constellation": "sentinel-2",
                "eo:cloud_cover": 5.96,
                "platform": "sentinel-2b"
            }
        },
        {
            "id": "S2A_MSIL2A_20220512T095031_N0400_R079_T33TYL_20220512T143915",
            "properties": {
                "datetime": "2022-05-12T09:58:02Z",
                "constellation": "sentinel-2",
                "eo:cloud_cover": 0.0,
                "platform": "sentinel-2a"
            }
        },
        {
            "id": "S2A_MSIL2A_20220509T094041_N0400_R036_T33TYL_20220509T163418",
            "properties": {
                "datetime": "2022-05-09T09:48:06Z",
                "constellation": "sentinel-2",
                "eo:cloud_cover": 19.6,
                "platform": "sentinel-2a"
            }
        },
        {
            "id": "S2B_MSIL2A_20220507T095029_N0400_R079_T33TYL_20220507T114721",
            "properties": {
                "datetime": "2022-05-07T09:57:54Z",
                "constellation": "sentinel-2",
                "eo:cloud_cover": 99.99,
                "platform": "sentinel-2b"
            }
        },
        {
            "id": "S2B_MSIL2A_20220504T094029_N0400_R036_T33TYL_20220504T124744",
            "properties": {
                "datetime": "2022-05-04T09:47:57Z",
                "constellation": "sentinel-2",
                "eo:cloud_cover": 26.38,
                "platform": "sentinel-2b"
            }
        },
        {
            "id": "S2A_MSIL2A_20220502T095031_N0400_R079_T33TYL_20220502T140620",
            "properties": {
                "datetime": "2022-05-02T09:58:03Z",
                "constellation": "sentinel-2",
                "eo:cloud_cover": 97.34,
                "platform": "sentinel-2a"
            }
        }
    ],
    "links": [
        {
            "href": "http://services.sentinel-hub.com/api/v1/catalog/search",
            "rel": "self",
            "type": "application/json"
        }
    ],
    "context": {
        "limit": 100,
        "returned": 10
    }
}

Statistical API

Request (leaving out NDVI Evalscript for brevity):

{
  "input": {
   "bounds": {
      "geometry": {
          "type": "Polygon",
          "coordinates": [[[18.394922043052787,45.538507554149675],[18.404536366875135,45.52966827663937],[18.40702579000876,45.530991250113885],[18.397153939654004,45.53971006956863],[18.394922043052787,45.538507554149675]]]
        },
    "properties": {
        "crs": "http://www.opengis.net/def/crs/EPSG/0/32633"
        }
    },
    "data": [
      {
        "type": "sentinel-2-l2a",
        "dataFilter": {
            "mosaickingOrder": "mostRecent"
        } 
      }
    ]
  },
  "aggregation": {
    "timeRange": {
        "from": "2022-05-01T00:00:00Z",
        "to": "2022-05-25T00:00:00Z"
      },
    "aggregationInterval": {
        "of": "P1D"
    }
  }
}

Response:

{
    "data": [
        {
            "interval": {
                "from": "2022-05-01T00:00:00Z",
                "to": "2022-05-02T00:00:00Z"
            },
            "outputs": {
                "data": {
                    "bands": {
                        "NDVI": {
                            "stats": {
                                "min": 0.7213114500045776,
                                "max": 0.7213114500045776,
                                "mean": 0.7213114500045776,
                                "stDev": 0.0,
                                "sampleCount": 65536,
                                "noDataCount": 47270
                            }
                        }
                    }
                }
            }
        },
        {
            "interval": {
                "from": "2022-05-06T00:00:00Z",
                "to": "2022-05-07T00:00:00Z"
            },
            "outputs": {
                "data": {
                    "bands": {
                        "NDVI": {
                            "stats": {
                                "min": 0.14255091547966003,
                                "max": 0.14255091547966003,
                                "mean": 0.14255091547966003,
                                "stDev": 0.0,
                                "sampleCount": 65536,
                                "noDataCount": 47270
                            }
                        }
                    }
                }
            }
        },
        {
            "interval": {
                "from": "2022-05-11T00:00:00Z",
                "to": "2022-05-12T00:00:00Z"
            },
            "outputs": {
                "data": {
                    "bands": {
                        "NDVI": {
                            "stats": {
                                "min": -0.05922165885567665,
                                "max": -0.05922165885567665,
                                "mean": -0.05922165885567665,
                                "stDev": 0.0,
                                "sampleCount": 65536,
                                "noDataCount": 47270
                            }
                        }
                    }
                }
            }
        },
        {
            "interval": {
                "from": "2022-05-16T00:00:00Z",
                "to": "2022-05-17T00:00:00Z"
            },
            "outputs": {
                "data": {
                    "bands": {
                        "NDVI": {
                            "stats": {
                                "min": 0.7916181683540344,
                                "max": 0.7916181683540344,
                                "mean": 0.7916181683540344,
                                "stDev": 0.0,
                                "sampleCount": 65536,
                                "noDataCount": 47270
                            }
                        }
                    }
                }
            }
        },
        {
            "interval": {
                "from": "2022-05-21T00:00:00Z",
                "to": "2022-05-22T00:00:00Z"
            },
            "outputs": {
                "data": {
                    "bands": {
                        "NDVI": {
                            "stats": {
                                "min": 0.04564705863595009,
                                "max": 0.04564705863595009,
                                "mean": 0.04564705863595009,
                                "stDev": 0.0,
                                "sampleCount": 65536,
                                "noDataCount": 47270
                            }
                        }
                    }
                }
            }
        }
    ],
    "status": "OK"
}

Since we’re using 1 day (P1D) aggregation interval, we would expect interval dates in Statistical API response to correspond to the dates returned in the Catalog API response, but this is not the case.

E.g. the one before last feature in Catalog API response has the datetime of “2022-05-04T09:47:57Z”,
while the Statistical API response does not provide an interval with this date included.

Are we missing something?

Thanks!

Hi Bruno,

Thanks for the detailed explanation of the problem

The one thing going amiss is the CRS.

Please note that the CRS to specify, is the CRS associated with the geometry provided. In your case, the provided geometry is in 4326, not 32633. That’s why Statistical API interpreted the geometry to be in a totally different location. Not as you intended.

In your case , below is the right crs to specify, and with this you should get matching results

      "properties": {
        "crs": "http://www.opengis.net/def/crs/EPSG/0/4326"
      }

Best

Hi Dorothy,

Thank you for the instructions. It worked perfectly and we’re now getting the expected intervals for the polygon from Statistical API!

Regards!