Install & Compatibility
Where this runs
tested against v1.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
40MB installed
● package 40MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
planetary_computer
✓ import planetary_computer
sign
✓ from planetary_computer import sign
Used for manual signing of URLs or PySTAC objects.
sign_inplace
✓ from planetary_computer import sign_inplace
Recommended for automatic signing of results from pystac-client.
This quickstart demonstrates how to connect to the Planetary Computer STAC API using `pystac-client`, perform a geospatial and temporal search for a Landsat image, and automatically sign the resulting asset URLs using `planetary_computer.sign_inplace`. It then shows how to open a signed Cloud Optimized GeoTIFF (COG) asset using `rasterio`. An optional environment variable `PC_SDK_SUBSCRIPTION_KEY` can be set for improved rate limits.
import os
import planetary_computer as pc
from pystac_client import Client
import rasterio
# Optionally set your Planetary Computer API subscription key for higher rate limits
# os.environ['PC_SDK_SUBSCRIPTION_KEY'] = os.environ.get('PC_SDK_SUBSCRIPTION_KEY', '')
# Open the Planetary Computer STAC API endpoint
# Using sign_inplace ensures all assets retrieved through this client are automatically signed
catalog = Client.open(
"https://planetarycomputer.microsoft.com/api/stac/v1",
modifier=pc.sign_inplace
)
# Define a bounding box and time range for a search (e.g., Landsat 8 image in Seattle area)
bbox = [-122.33, 47.60, -122.00, 47.75]
time_range = "2020-01-01/2020-01-31"
# Search for Landsat C2 L2 items
search = catalog.search(
collections=["landsat-c2-l2"],
bbox=bbox,
datetime=time_range,
query={'eo:cloud_cover': {'lt': 10}} # Example: filter for low cloud cover
)
# Get the first item from the search results
items = search.item_collection()
if items:
first_item = items[0]
print(f"Found item: {first_item.id}")
# Access a signed asset (e.g., the red band)
red_band_asset = first_item.assets["SR_B4"]
signed_href = red_band_asset.href
print(f"Signed URL for red band: {signed_href[:100]}...")
# Open the signed asset with rasterio
try:
with rasterio.open(signed_href) as ds:
print(f"Successfully opened asset with shape: {ds.shape}, CRS: {ds.crs}")
# You can now read data, e.g., ds.read(1)
except Exception as e:
print(f"Error opening asset: {e}")
else:
print("No items found for the given search criteria.")
Debug
Known issues
gotchaForgetting to sign asset URLs will result in 404 'Not Found' errors when attempting to access data from Azure Blob Storage. Data hosted on the Planetary Computer requires Shared Access Signature (SAS) tokens for authorized access.fixEnsure you pass `modifier=planetary_computer.sign_inplace` when initializing `pystac_client.Client.open()` or manually call `planetary_computer.sign()` on individual assets/items before attempting to access their `href`s.
affects: All versions
breakingIn the May 2023 release, the underlying raster tiling engine (TiTiler) was upgraded, which introduced changes to how rendering parameters are specified when generating image tiles via the `/api/data/` endpoints (Item Tile and Mosaic Tile endpoints).fixReview the changelog and upstream `pgstac-titiler` and `rio-tiler` documentation for updated rendering parameter specifications if you are directly interacting with the Planetary Computer's Data API tile endpoints.
affects: May 2023 onwards (prior to 1.0.0, but relevant for users interacting with the API directly)
deprecatedThe Planetary Computer Hub (a hosted Jupyter environment) was retired on June 6th, 2024, due to enhanced security requirements. This affects user workflows that relied on the pre-configured Hub environment.fixUsers should transition to local development environments or other Azure compute services (e.g., Azure Machine Learning compute instances, Azure Functions) to run their Python analyses. Data and APIs remain available.
affects: All versions (impacts user environment, not library code)
gotchaAnonymous access to Planetary Computer data is rate-limited. For un-throttled access and longer-lived tokens, users should either register for a Planetary Computer API subscription key or perform their work within the West Europe Azure region.fixSet the `PC_SDK_SUBSCRIPTION_KEY` environment variable with your API key or configure it via `planetarycomputer configure`. If possible, utilize Azure compute resources within the West Europe region.
affects: All versions
Upgrade
Version history
1.0.0latest on PyPI · released Jul 5, 2023
Audit
Dependencies
pystacrequiredCore STAC object model for items and collections.
pystac-clientrequiredClient for querying STAC APIs, commonly used with the Planetary Computer STAC endpoint.
rasteriooptionalUsed for reading Cloud Optimized GeoTIFFs (COGs) after signing.
stackstacoptionalFor creating Dask DataArrays from STAC item collections, enabling scalable processing.
xarrayoptionalFor N-dimensional array processing, often used with stackstac.
daskoptionalFor scalable, out-of-core computation with large datasets.