Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Add PC STAC client configuration #8

Merged
merged 1 commit into from
Aug 4, 2023
Merged

Add PC STAC client configuration #8

merged 1 commit into from
Aug 4, 2023

Conversation

giorgiobasile
Copy link
Owner

Provides a PC-configured PySTAC client, able to sign assets, even those requiring a subscription key.

See PC - Using Tokens for Data Access tutorial for more information regarding SAS Tokens and assets' signing.

Closes #6

Example

from prefect import flow
from prefect_planetary_computer import PlanetaryComputerCredentials

@flow
def example_get_stac_catalog_flow():

    pc_credentials_block = PlanetaryComputerCredentials(
        subscription_key = "sub-key",
        hub_api_token = "hub-token"
    )
    catalog = pc_credentials_block.get_stac_catalog()
    
    # Search STAC catalog for Landsat Collection 2 Level 2 items
    time_range = "2020-12-01/2020-12-31"
    bbox = [-122.2751, 47.5469, -121.9613, 47.7458]
    search = catalog.search(collections=["landsat-c2-l2"], bbox=bbox, datetime=time_range)
    
    items = search.get_all_items()
    return len(items)
    
example_get_stac_catalog_flow()

Screenshots

Checklist

  • References any related issue by including "Closes #" or "Closes ".
    • If no issue exists and your change is not a small fix, please create an issue first.
  • Includes tests or only affects documentation.
  • Passes pre-commit checks.
    • Run pre-commit install && pre-commit run --all locally for formatting and linting.
  • Includes screenshots of documentation updates.
    • Run mkdocs serve view documentation locally.
  • Summarizes PR's changes in CHANGELOG.md

@giorgiobasile giorgiobasile added the enhancement New feature or request label Aug 4, 2023
@giorgiobasile giorgiobasile self-assigned this Aug 4, 2023
@giorgiobasile giorgiobasile merged commit 7e6fea1 into main Aug 4, 2023
@giorgiobasile giorgiobasile deleted the pc-stac-client branch August 4, 2023 20:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a PC credentials block and related clients
1 participant