sentinel-hub / sentinelhub-py

Download and process satellite imagery in Python using Sentinel Hub services.
http://sentinelhub-py.readthedocs.io/en/latest/
MIT License
798 stars 243 forks source link

[BUG] Can't add the 'constellation' filter to a request #520

Closed jovanovski closed 6 months ago

jovanovski commented 6 months ago

Describe the bug

The constellation data filter needed for HLS requests can't be added. If added to the other_args dict, it's being put outside the data_filters object, hence not used.

To Reproduce

Steps to reproduce the behavior:

  1. Request ThermalInfrared1 band from HLS
  2. Get error that you need to use the constellation filter
  3. No way to add the filter without modifying the library

Expected behavior

To be able to add this filter

Server response: "{"status": 400, "reason": "Bad Request", "message": "Your request returns SENTINEL products, which don't have bands ThermalInfrared1, ThermalInfrared2. Filter out such products, e.g. using 'constellation' filter.", "code": "COMMON_BAD_PAYLOAD"}"

Desktop (please complete the following information):

Additional context

Here is the request and you can see how other_args adds the value outside of data_filters

'data': [InputDataDict({'type': 'hls', 'dataFilter': {'timeRange': {'from': '2023-04-20T00:00:00Z', 'to': '2023-05-03T23:59:59Z'}, 'maxCloudCoverage': 70, 'mosaickingOrder': 'leastCC'}, 'constellation': 'landsat'}, service_url=https://services-uswest2.sentinel-hub.com/)]},

If I manually edit the library and force it inside the data filters, the request works.

zigaLuksic commented 6 months ago

Hi @jovanovski

i agree that it is often a bit messy to add specific filters. But you approach with other_args should work. The code joins the two dictionaries, and since you want "constellation": "LANDSAT" to be in the "dataFilter" you can do this:

input_data=[
        SentinelHubRequest.input_data(
            data_collection=DataCollection.HARMONIZED_LANDSAT_SENTINEL,
            time_interval=("2020-06-12", "2020-06-30"),
            other_args={"dataFilter": {"constellation": "LANDSAT"}}
        )
    ]

I was able to get an image with the above. If the issues remain we can try and resolve them.

jovanovski commented 6 months ago

Ah, yes, you're right @zigaLuksic! Thank you for the hint!