stac-utils / stac-utils/pystac-client
Error with using `max_items` and `sortby` parameters with the LandsatLook endpoint
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 209
- Forks
- 64
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 6
Description
When submitting a search to the Landsat STAC API with PySTAC setting both max_items and sortby parameters, the returned results are repeated to match the max_items value, e.g., this search setup has only 4 scenes that satisfy it, but 10 are returned, which is the set max_items value in the search :
landsat_stac = Client.open('https://landsatlook.usgs.gov/stac-server')
query_returns = landsat_stac.search(
collections=['landsat-c2ard-sr'],
datetime=f"2023-11-03/2023-11-03",
max_items=10,
intersects=river_linestring,
sortby=[
{'field': 'properties.landsat:grid_vertical', 'direction': 'asc'},
{'field': 'properties.landsat:grid_horizontal', 'direction': 'asc'}
]
).item_collection_as_dict()['features']
Of the 10 returned, the metadata dictionary for 2 scenes is repeated 3 times, while the other 2 are repeated 2 times.
When the line of code is run without the max_items flag, the "pulling" of metadata from the Landsat STAC continues, seemingly with no end.
Is there a potential fix to this, or is this snippet incorrectly formatted?
Thank you,
Toni
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided Client.open and search call against the Landsat STAC endpoint, comparing results with and without max_items and sortby. Trace how PySTAC Client handles pagination and item collection assembly, then verify that matching scenes are returned once and that an uncapped search terminates normally.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100