nasa/EMIT-Data-Resources

How to filter cloud_cover for EMIT data using pystac?

zxdawn opened this issue · 3 comments

zxdawn commented
from pystac_client import Client

url = 'https://cmr.earthdata.nasa.gov/stac/LPCLOUD/?page=2'
collections = ['EMITL1BRAD.v001', 'EMITL1BRAD.v001']
bbox = [-99.65, 18.85, -98.5, 19.95]
date_range = "2022-05/2023-08"

catalog = Client.open(url)

params = {
'collections': collections,
'bbox': bbox,
'datetime': date_range,
'limit': 100,
}

filt = {
    "op": "lte",
    "args": [{"property": "eo:cloud_cover"}, 40]
}

# params['filter'] = filt

search = catalog.search(**params)

print('Matching STAC Items:', search.matched())

It works well without the cloud_cover filter. However, I get this error if I try to add the filter:

    215     raise APIError(str(err))
    216 if resp.status_code != 200:
--> 217     raise APIError.from_response(resp)
    218 try:
    219     return resp.content.decode("utf-8")

APIError: {"message":"If the problem persists please contact cmr-support@earthdata.nasa.gov","errors":["An unexpected error occurred. We have been alerted and are working to resolve the problem.","Unsupported parameter filter"]}

Is this not supported yet? Otherwise, I have to access the cloud_cover properties from the collections:

image

Hey @zxdawn, the current implementation of the CMR STAC API does not support filtering based on those properties. I think it's an important capability to include, but I can't tell you when or if that would be available. An alternative option would be to use the earthaccess package. I've include a code snippet below.

search_params = {
    "concept_id": "C2408009906-LPCLOUD", # CMR concept ID for EMITL1BRAD.001
    #"day_night_flag": "day",
    "cloud_cover": (0, 10),
    "temporal": ("2022-05", "2023-08"),
    "bounding_box": (-99.65, 18.85, -98.5, 19.95)
}

results = earthaccess.search_data(**search_params)

# Get links to data...  note that EMITL1BRAD.001 contains 2 data files per 'granule'
[x.data_links() for x in results]
zxdawn commented

Thanks! It works well. Close now ;)

zxdawn commented

It would be nice to see the support of pystac. It's useful to use pystac to check the RGB data quickly.