cmr-stac
cmr-stac copied to clipboard
'limit' does not work as expected
trafficstars
I've noticed using the 'limit' keyword is either ignored, or causes API failures if set to a large value (>1000)
import pystac_client #0.3
URL = 'https://cmr.earthdata.nasa.gov/stac/NSIDC_ECS'
catalog = pystac_client.Client.open(URL)
results = catalog.search(
collections=['NSIDC-0723.v4'],
bbox = '-54.85,69.31,-52.18,70.26',
datetime='2000-01-01/2021-12-31',
limit=20,
)
# For limit=20
print(f"{results.matched()} items found") # 1387 items found (expecting 20)
items = results.get_all_items_as_dict()
print(len(items['features'])) # 1387
# For limit=1000
print(f"{results.matched()} items found") # 1387 items found (expecting 1000)
print(results.get_all_items_as_dict()) # {'type': 'FeatureCollection', 'features': []}
seemingly related https://github.com/nasa/cmr-stac/issues/192, https://github.com/nasa/cmr-stac/issues/152#issuecomment-828187861 cc @matthewhanson
A point of clarification. limit affects the number of Items returned per page. Not to be confused with max_items which limits total number of Items.
results = catalog.search(
collections=['NSIDC-0723.v4'],
bbox = '-54.85,69.31,-52.18,70.26',
datetime='2000-01-01/2021-12-31',
max_items=20,
)
print(results.matched()) # 1387 (expecting 20)
print(len(results.get_all_items())) # 20
I think there are still issues identified above.
matched()reflects the unfiltered search hits (max_itemsnot considered).- a high value for
limitresults in zero features being returned.