{"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.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install planetary-computer pystac-client","pip install 'planetary-computer[io]' pystac-client stackstac rasterio xarray dask"],"cli":null},"imports":["import planetary_computer","from planetary_computer import sign","from planetary_computer import sign_inplace"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}