{"id":9184,"library":"planetary-computer","title":"Planetary Computer SDK","description":"The Planetary Computer SDK for Python (version 1.0.0) provides a client library for interacting with the Microsoft Planetary Computer, a platform that offers petabytes of Earth observation data and computational resources. It simplifies programmatic access to the SpatioTemporal Asset Catalog (STAC) API, handles data authentication by signing Azure Blob Storage URLs with Shared Access Signature (SAS) tokens, and facilitates integration with other open-source geospatial Python libraries. The project maintains an active development status with frequent updates for datasets and features, with new dataset releases typically on a roughly quarterly cadence.","status":"active","version":"1.0.0","language":"en","source_language":"en","source_url":"https://github.com/microsoft/planetary-computer-sdk-for-python","tags":["geospatial","earth-observation","stac","azure","cloud-computing","data-access","remote-sensing","environmental-data"],"install":[{"cmd":"pip install planetary-computer pystac-client","lang":"bash","label":"Install core libraries"},{"cmd":"pip install 'planetary-computer[io]' pystac-client stackstac rasterio xarray dask","lang":"bash","label":"Install with common I/O and processing dependencies"}],"dependencies":[{"reason":"Core STAC object model for items and collections.","package":"pystac","optional":false},{"reason":"Client for querying STAC APIs, commonly used with the Planetary Computer STAC endpoint.","package":"pystac-client","optional":false},{"reason":"Used for reading Cloud Optimized GeoTIFFs (COGs) after signing.","package":"rasterio","optional":true},{"reason":"For creating Dask DataArrays from STAC item collections, enabling scalable processing.","package":"stackstac","optional":true},{"reason":"For N-dimensional array processing, often used with stackstac.","package":"xarray","optional":true},{"reason":"For scalable, out-of-core computation with large datasets.","package":"dask","optional":true}],"imports":[{"symbol":"planetary_computer","correct":"import planetary_computer"},{"note":"Used for manual signing of URLs or PySTAC objects.","symbol":"sign","correct":"from planetary_computer import sign"},{"note":"Recommended for automatic signing of results from pystac-client.","symbol":"sign_inplace","correct":"from planetary_computer import sign_inplace"}],"quickstart":{"code":"import os\nimport planetary_computer as pc\nfrom pystac_client import Client\nimport rasterio\n\n# Optionally set your Planetary Computer API subscription key for higher rate limits\n# os.environ['PC_SDK_SUBSCRIPTION_KEY'] = os.environ.get('PC_SDK_SUBSCRIPTION_KEY', '')\n\n# Open the Planetary Computer STAC API endpoint\n# Using sign_inplace ensures all assets retrieved through this client are automatically signed\ncatalog = Client.open(\n    \"https://planetarycomputer.microsoft.com/api/stac/v1\",\n    modifier=pc.sign_inplace\n)\n\n# Define a bounding box and time range for a search (e.g., Landsat 8 image in Seattle area)\nbbox = [-122.33, 47.60, -122.00, 47.75]\ntime_range = \"2020-01-01/2020-01-31\"\n\n# Search for Landsat C2 L2 items\nsearch = catalog.search(\n    collections=[\"landsat-c2-l2\"],\n    bbox=bbox,\n    datetime=time_range,\n    query={'eo:cloud_cover': {'lt': 10}} # Example: filter for low cloud cover\n)\n\n# Get the first item from the search results\nitems = search.item_collection()\nif items:\n    first_item = items[0]\n    print(f\"Found item: {first_item.id}\")\n\n    # Access a signed asset (e.g., the red band)\n    red_band_asset = first_item.assets[\"SR_B4\"]\n    signed_href = red_band_asset.href\n    print(f\"Signed URL for red band: {signed_href[:100]}...\")\n\n    # Open the signed asset with rasterio\n    try:\n        with rasterio.open(signed_href) as ds:\n            print(f\"Successfully opened asset with shape: {ds.shape}, CRS: {ds.crs}\")\n            # You can now read data, e.g., ds.read(1)\n    except Exception as e:\n        print(f\"Error opening asset: {e}\")\nelse:\n    print(\"No items found for the given search criteria.\")","lang":"python","description":"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."},"warnings":[{"fix":"Ensure 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.","message":"Forgetting 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review 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.","message":"In 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).","severity":"breaking","affected_versions":"May 2023 onwards (prior to 1.0.0, but relevant for users interacting with the API directly)"},{"fix":"Users 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.","message":"The 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.","severity":"deprecated","affected_versions":"All versions (impacts user environment, not library code)"},{"fix":"Set 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.","message":"Anonymous 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure your network proxy settings are correctly configured for Python, or consult your IT department. You may need to set environment variables like `HTTP_PROXY` and `HTTPS_PROXY` or configure your Python environment to bypass the proxy for specific domains.","cause":"This error typically indicates an issue with network proxy configuration preventing the client from reaching the Planetary Computer API endpoints.","error":"Failed to retrieve collections from ... The proxy tunnel request ... failed with status code '407'."},{"fix":"Verify that `planetary_computer.sign_inplace` is being used correctly when opening the STAC client, or that `planetary_computer.sign()` is explicitly called on assets before accessing their `href`. Also, ensure your `PC_SDK_SUBSCRIPTION_KEY` (if used) is valid and provides sufficient access, and consider the token expiry mentioned in warnings.","cause":"This error most commonly occurs when trying to access an Azure Blob Storage URL (ABFS) without a valid or correctly applied Shared Access Signature (SAS) token, or if the token has expired.","error":"Read failed: The server failed to authenticate the request for ABFS."},{"fix":"Refine your STAC API queries to be more specific (e.g., tighter bounding box, shorter time range, more precise property filters). If processing large datasets, consider using Dask with `stackstac` to efficiently handle data and avoid pulling all assets into memory.","cause":"This usually indicates a timeout on the Planetary Computer STAC API or Data API due to a complex query, a large number of results, or transient network issues.","error":"APIError: The request exceeded the maximum allowed time, please try again."},{"fix":"Thoroughly review the STAC JSON files for compliance with the STAC specification, ensure all referenced collections exist, and verify that all asset files are valid, accessible from the ingestion source, and in supported formats. Consult the Planetary Computer Pro ingestion troubleshooting documentation for specific error codes.","cause":"These errors occur when ingesting data into a Planetary Computer Pro GeoCatalog and are related to invalid STAC metadata, missing collections, or issues with the underlying asset files (e.g., corrupt GeoTIFFs, inaccessible URLs).","error":"STAC validation errors during data ingestion (e.g., 'CollectionDoesNotExist', 'EmptyAsset', 'AssetTransformationError')."}]}