Skip to main content

Planetary Computer SDK for Python

Project description

Planetary Computer SDK for Python

Python library for interacting with the Microsoft Planetary Computer.

For general questions or discussions about the Planetary Computer, use the microsoft/PlanetaryComputer repository.

Installation

pip install planetary-computer

If you have an API subscription key, you may provide it to the library by using the included configuration CLI:

planetarycomputer configure

Alternatively, a subscription key may be provided by specifying it in the PC_SDK_SUBSCRIPTION_KEY environment variable. A subcription key is not required for interacting with the service, however having one in place allows for less restricted rate limiting.

Development

The following steps may be followed in order to develop locally:

## Create and activate venv
python3 -m venv env
source env/bin/activate

## Install requirements
python3 -m pip install -r requirements-dev.txt

## Install locally
pip install -e .

## Format code
./scripts/format

## Run tests
./scripts/test

Usage

This library currently assists with signing Azure Blob Storage URLs. The sign function operates directly on an HREF string, as well as several PySTAC objects: Asset, Item, and ItemCollection. In addition, the sign function accepts a STAC API Client ItemSearch, which performs a search and returns the resulting ItemCollection with all assets signed. The following example demonstrates these use cases:

from pystac import Asset, Item, ItemCollection
from pystac_client import ItemSearch
import planetary_computer as pc


# The sign function may be called directly on the Item
raw_item: Item = ...
item: Item = pc.sign(raw_item)
# Now use the item however you want. All appropriate assets are signed for read access.

# The sign function also works with an Asset
raw_asset: Asset = raw_item.assets['SR_B4']
asset = pc.sign(raw_asset)

# The sign function also works with an HREF
raw_href: str = raw_asset.href
href = pc.sign(raw_href)

# The sign function also works with an ItemCollection
raw_item_collection = ItemCollection([raw_item])
item_collection = pc.sign(raw_item_collection)

# The sign function also accepts an ItemSearch, and signs the resulting ItemCollection
search = ItemSearch(
    url=...,
    bbox=...,
    collections=...,
    limit=...,
    max_items=...,
)
signed_item_collection = pc.sign(search)

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

planetary-computer-0.4.4.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

planetary_computer-0.4.4-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file planetary-computer-0.4.4.tar.gz.

File metadata

  • Download URL: planetary-computer-0.4.4.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for planetary-computer-0.4.4.tar.gz
Algorithm Hash digest
SHA256 69cc4dd94d937c52a7c3cd59704e2a8873eec0cbb8cad67347be02bb9b4eb036
MD5 1fc8885268b07b94a0c01f4b5e18772b
BLAKE2b-256 1848f16d321a634b841846208e373513d177af05282baed6eb4c24a9b9c0be27

See more details on using hashes here.

File details

Details for the file planetary_computer-0.4.4-py3-none-any.whl.

File metadata

  • Download URL: planetary_computer-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for planetary_computer-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 384de997aef395b21287410d74cd253e9a0a2d2dbe9f73125cd08109ab559614
MD5 de3b54017bc2b706eb5181eddc978909
BLAKE2b-256 60b5a1a72a33226bf0a78617bd5bf1dea236f6da92a827714a5c1a330d9b2e08

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page