Sentinel Data On-Demand: Querying ESA APEx & Copernicus STAC API with Python

Streamline Your Sentinel Workflow with STAC and pystac-client

For geospatial data scientists, the days of manually downloading massive Sentinel granules are over. The European Space Agency (ESA) now provides APEx (Advanced Products Explorer) and the Copernicus STAC API, enabling efficient, on-demand access to analysis-ready data. In this walkthrough, we’ll show you how to use pystac-client in Python to query and stream only the bounding boxes you need—without downloading entire scenes. This approach slashes storage costs, speeds up processing, and accelerates insights for agriculture, carbon verification, and supply chain monitoring.

Why STAC and APEx Matter for Your Pipeline

STAC (SpatioTemporal Asset Catalog) is a standardized JSON specification that makes geospatial assets discoverable and queryable. ESA’s APEx builds on this by providing a unified API for Sentinel-1, Sentinel-2, and other Copernicus data. By leveraging the STAC API, you can:

  • Filter by bounding box, time range, and cloud cover to retrieve only relevant scenes.
  • Stream data directly into your Python environment using libraries like rioxarray or stackstac, avoiding local storage bloat.
  • Integrate seamlessly with cloud-native workflows (e.g., AWS Lambda, Google Earth Engine).

For agtech enterprises, this means faster crop health assessments, near-real-time deforestation alerts, and more accurate carbon stock estimates.

Step-by-Step: Querying Sentinel Data with pystac-client

Let’s dive into a practical example. We’ll query Sentinel-2 L2A data over a specific agricultural region and stream only the red and NIR bands for NDVI calculation.

1. Install Required Libraries

pip install pystac-client rioxarray rasterio matplotlib

2. Connect to the Copernicus STAC API

from pystac_client import Client

# ESA APEx STAC endpoint
api_url = "https://catalogue.dataspace.copernicus.eu/stac"
client = Client.open(api_url)

3. Define Your Area of Interest and Time Range

# Bounding box for a field in Iowa (lon_min, lat_min, lon_max, lat_max)
bbox = [-93.65, 41.95, -93.60, 42.00]
date_range = "2024-06-01/2024-06-30"

search = client.search(
    collections=["SENTINEL-2"],
    bbox=bbox,
    datetime=date_range,
    query={"eo:cloud_cover": {"lt": 10}}
)
items = search.item_collection()
print(f"Found {len(items)} items")

4. Stream Only the Bands You Need

Instead of downloading full granules, use rioxarray to open the remote COG (Cloud Optimized GeoTIFF) assets and clip to your bbox on-the-fly.

import rioxarray
import numpy as np

# Select the least cloudy item
item = min(items, key=lambda x: x.properties["eo:cloud_cover"])

# Get URLs for red and NIR bands
red_url = item.assets["B04"].href
nir_url = item.assets["B08"].href

# Open and clip to bbox
red = rioxarray.open_rasterio(red_url, chunks=True).rio.clip_box(*bbox)
nir = rioxarray.open_rasterio(nir_url, chunks=True).rio.clip_box(*bbox)

# Compute NDVI
ndvi = (nir - red) / (nir + red)
ndvi.plot(cmap="RdYlGn")

This method streams only the necessary pixels, reducing data transfer by up to 90% compared to full-granule downloads.

Impact for AgTech and Carbon Projects

By adopting STAC-based workflows, geospatial teams can:

  • Scale monitoring across thousands of fields without exponential storage costs.
  • Automate crop health alerts by integrating with platforms like GaiaTrace’s Satellite Crop Health solution, which uses similar streaming techniques to deliver actionable insights.
  • Enhance carbon verification with frequent, high-resolution biomass estimates.

For B2B agriculture enterprises, this means faster time-to-insight, lower operational costs, and more robust sustainability reporting.

Practical Takeaways

  • Start small: Test the STAC API with a single field before scaling to a portfolio.
  • Leverage cloud-native formats: Always prefer COGs and streaming over downloads.
  • Integrate with existing platforms: Combine STAC queries with tools like GaiaTrace to operationalize insights without building from scratch.
  • Monitor API changes: ESA’s APEx is evolving; stay updated via the Copernicus Data Space Ecosystem.

Ready to supercharge your geospatial pipeline? Explore how GaiaTrace can help you turn Sentinel data into decision-ready intelligence for crop health, carbon, and supply chain resilience.