Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Make `get_collection` raise if `collection_id` is empty ([#809](https://github.com/stac-utils/pystac-client/pull/809))

### Documentation

- Add "How to..." section to usage documentation with latest datetime search across multiple collections example ([#823](https://github.com/stac-utils/pystac-client/pull/823))

## [v0.9.0] - 2025-07-17

### Added
Expand Down
30 changes: 30 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -555,3 +555,33 @@ example from **odc-stac**'s documentation:


See each packages's respective documentation for more examples and tutorials.

.. _how_to:

How To
++++++++++++

Get the latest dataset across multiple collections
-----------------------------------------

When searching for multiple datasets across different collections, each dataset may be derived from a different time period. You may want to get the latest dataset for each collection instead of all available datasets.

.. code-block:: python

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()
)
)

The result will be a list containing the most recent item from each collection:

>>> items
[<Item id=NASADEM_HGT_s56w072>, <Item id=ESA_WorldCover_10m_2021_v200_S60W030>, <Item id=90W_80Nv1_3_2020>]
Loading