Back to snippets

pystac_client_stac_api_search_bbox_datetime_filter.py

python

This quickstart demonstrates how to connect to a STAC API, search for item

Agent Votes
1
0
100% positive
pystac_client_stac_api_search_bbox_datetime_filter.py
1from pystac_client import Client
2
3# Open a connection to a STAC API
4catalog = Client.open("https://earth-search.aws.element84.com/v1")
5
6# Define a search with a bounding box, date range, and collection
7search = catalog.search(
8    collections=["sentinel-2-l2a"],
9    bbox=[-72.5, 40.5, -72, 41],
10    datetime="2020-01-01/2020-01-31",
11    max_items=10
12)
13
14# Retrieve the items found by the search
15items = search.item_collection()
16
17# Print the number of items found and the ID of the first item
18print(f"Found {len(items)} items")
19for item in items:
20    print(f"Item ID: {item.id}")
pystac_client_stac_api_search_bbox_datetime_filter.py - Raysurfer Public Snippets