Open ben-epoch-blue opened 4 weeks ago
This isn't too hard to implement now:
from pystac_client import Client
client = Client.open("https://planetarycomputer.microsoft.com/api/stac/v1")
items = []
for collection in ["nasadem", "esa-worldcover", "jrc-gsw"]:
items.append(
next(
client.search(
collections=[collection], max_items=1, sortby="-properties.datetime"
).items()
)
)
# items == [<Item id=NASADEM_HGT_s56w072>, <Item id=ESA_WorldCover_10m_2021_v200_S60W030>, <Item id=90W_80Nv1_3_2020>]
I don't personally think this is a common-enough pattern to be worth building functionality around, but I'll leave this issue open to collect comments if others think differently.
Thank you for taking the time to write up the code!
I think it's a common use case for non-temporal analysis (in my case, creating cost layers) as there's no need for older datasets
This is a good example of the type of thing that might be documented in a "How to..." section of the docs. Something like this: https://docs.xarray.dev/en/stable/howdoi.html
I am trying to search for multiple datasets:
However, each dataset is derived from a different time period. I would like to get the latest dataset for each collection instead of all available datasets