-
When searching Planetary Computer's STAC I noticed that the For example, the following search returns 150 items: import planetary_computer
import pystac_client
client = pystac_client.Client.open(
"https://planetarycomputer.microsoft.com/api/stac/v1",
modifier=planetary_computer.sign_inplace
)
search = client.search(
collections=["sentinel-2-l2a"],
datetime="2021-12-17/2022-12-17",
query={
"s2:mgrs_tile": {"eq": "50QMJ"}
}
)
len(search.item_collection())
>>> 150 while the same search with search = client.search(
collections=["sentinel-2-l2a"],
datetime="2021-12-17/2022-12-17",
query={
"s2:mgrs_tile": {"eq": "50QMJ"}
},
sortby="eo:cloud_cover",
)
len(search.item_collection())
>>> 148 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
🤔 I can't reproduce, using a modified version of your script intended to discover whether the missing ids are stable: import planetary_computer
import pystac_client
client = pystac_client.Client.open(
"https://planetarycomputer.microsoft.com/api/stac/v1",
modifier=planetary_computer.sign_inplace,
)
search = client.search(
collections=["sentinel-2-l2a"],
datetime="2021-12-17/2022-12-17",
query={"s2:mgrs_tile": {"eq": "50QMJ"}},
)
ids_without_sort = set()
for item in search.items():
ids_without_sort.add(item.id)
print(f"Without sort, {len(ids_without_sort)} items")
for _ in range(5):
search = client.search(
collections=["sentinel-2-l2a"],
datetime="2021-12-17/2022-12-17",
query={"s2:mgrs_tile": {"eq": "50QMJ"}},
sortby="eo:cloud_cover",
)
ids_with_sort = set()
for item in search.items():
ids_with_sort.add(item.id)
missing_ids = sorted(ids_without_sort - ids_with_sort)
if missing_ids:
print(f"With sort, {len(ids_with_sort)} items: {', '.join(missing_ids)}")
else:
print(f"With sort, {len(ids_with_sort)} items, none missing") Output:
|
Beta Was this translation helpful? Give feedback.
-
Hm. I was able to reproduce my earlier result on PCH with a fresh notebook and using the base image/env. And confirmed with your modified version: The "missing" Items appear to be stable:
|
Beta Was this translation helpful? Give feedback.
There's a similar/same issue reported on the Planetary Computer, who will likely be the folks to drive the fix in pgstac: microsoft/PlanetaryComputer#301. I've linked this discussion in over there, I'd watch that issue for updates.