Skip to content

Error with using max_items and sortby parameters with the LandsatLook endpoint #855

@tonianr

Description

@tonianr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingexternalIssues with an external STAC server, which often surface here

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions