- Notifications
You must be signed in to change notification settings - Fork21
Planetary Computer SDK for Python
License
microsoft/planetary-computer-sdk-for-python
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Python library for interacting with the Microsoft Planetary Computer.
For general questions or discussions about the Planetary Computer, use themicrosoft/PlanetaryComputer repository.
pipinstallplanetary-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 thePC_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.
This library assists with signing Azure Blob Storage URLs. Thesign
function operates directly on an HREF string, as well as severalPySTAC objects:Asset
,Item
, andItemCollection
. In addition, thesign
function accepts aSTAC API ClientItemSearch
, which performs a search and returns the resultingItemCollection
with all assets signed.
If you're using pystac-client we recommend you use its feature toautomatically sign results withplanetary_computer.sign_inplace
:
importplanetary_computerimportpystac_clientfrompystac_clientimportClientimportplanetary_computer,requestsapi=Client.open('https://planetarycomputer.microsoft.com/api/stac/v1',modifier=planetary_computer.sign_inplace,)
Now all the results you get from that client will be signed.
Alternatively, you can manually callplanetary_computer.sign
on your results.
frompystacimportAsset,Item,ItemCollectionfrompystac_clientimportItemSearchimportplanetary_computeraspc# The sign function may be called directly on the Itemraw_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 Assetraw_asset:Asset=raw_item.assets['SR_B4']asset=pc.sign(raw_asset)# The sign function also works with an HREFraw_href:str=raw_asset.hrefhref=pc.sign(raw_href)# The sign function also works with an ItemCollectionraw_item_collection=ItemCollection([raw_item])item_collection=pc.sign(raw_item_collection)# The sign function also accepts an ItemSearch, and signs the resulting ItemCollectionsearch=ItemSearch(url=...,bbox=...,collections=...,limit=...,max_items=...,)signed_item_collection=pc.sign(search)
You'll occasionally need to interact with the Blob Storage container directly, rather thanusing STAC items. We include two convenience methods for this:
planetary_computer.get_container_client
: Get anazure.storage.blob.ContainerClient
planetary_computer.get_adlfs_filesystem
: Get anadlfs.AzureBlobFilesystem
The following steps may be followed in order to develop locally:
## Create and activate venvpython3 -m venv envsource env/bin/activate## Install requirementspython3 -m pip install -r requirements-dev.txt## Install locallypip install -e .[adlfs,azure,dev]## Format code./scripts/format## Run tests./scripts/test
This project welcomes contributions and suggestions. Most contributions require you to agree to aContributor License Agreement (CLA) declaring that you have the right to, and actually do, grant usthe rights to use your contribution. For details, visithttps://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to providea CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructionsprovided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted theMicrosoft Open Source Code of Conduct.For more information see theCode of Conduct FAQ orcontactopencode@microsoft.com with any additional questions or comments.
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsofttrademarks or logos is subject to and must followMicrosoft'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.
About
Planetary Computer SDK for Python
Topics
Resources
License
Code of conduct
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors9
Uh oh!
There was an error while loading.Please reload this page.