Skip to content

Instantly share code, notes, and snippets.

@emileten
Created April 27, 2023 02:52
Show Gist options
  • Save emileten/5ef0586be2a3a95cdc82af206684e2b6 to your computer and use it in GitHub Desktop.
Save emileten/5ef0586be2a3a95cdc82af206684e2b6 to your computer and use it in GitHub Desktop.
count_items_in_collection_pystac
from pystac_client import Client
CATALOG_URL = '' # Replace with your catalog URL
COLLECTION_ID = '' # Replace with your collection ID
# Create a client to connect to the catalog
client = Client.open(CATALOG_URL)
for collection in client.get_all_collections():
print(f'Collection ID: {collection.id}')
collection = client.get_collection(COLLECTION_ID)
items = collection.get_all_items()
# get the length of the items. It's a generator, so we need to iterate through it.
length = len(list(items))
print(length)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment