Created
April 27, 2023 02:52
-
-
Save emileten/5ef0586be2a3a95cdc82af206684e2b6 to your computer and use it in GitHub Desktop.
count_items_in_collection_pystac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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