Read, download, and write STAC assets across platforms and providers
Project description
stac-asset
Download STAC Assets using a variety of authentication schemes.
Installation
pip install git+https://github.com/gadomski/stac-async
Usage
Download a STAC Item and all of its assets to a local directory. Each Asset's href will be updated to point to the local file.
from pystac import Item
href = "https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/simple-item.json"
item = Item.from_file(href)
from stac_async import HttpClient
client = await HttpClient.default()
await client.download_item(item, ".")
To download an item using the command line:
python -m stac_asset https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/simple-item.json .
Clients
This library comes with several clients, each tailored for a specific data provider model and authentication scheme. Some clients require some setup before use; they are called out in this table, and the details are provided below.
Name | Description | Notes |
---|---|---|
HttpClient |
Simple HTTP client without any authentication | |
S3Client |
Simple S3 client without any authentication | |
FilesystemClient |
Moves files from place to place on a local filesystem | Mostly used for testing |
PlanetaryComputerClient |
Signs urls with the Planetary Computer Authentication API | No additional setup required, works out of the box |
UsgsErosClient |
Uses a token-based authentication workflow to download data, e.g. landsat, from USGS EROS | Requires creation of a personal access token, see section below |
USGS EROS
The USGS EROS system, which hosts landsat data, requires a personal access token to download assets. Here's how to create and use your personal access token with stac-asset:
- Create a new personal access token
- Set two environment variables:
USGS_EROS_USERNAME
to your username (found in the top right of the web UI)USGS_EROS_PAT
to your personal access token
- Use
UsgsErosClient.login()
to create a new client.
You can also provide your username and password to the login
method.
Design goals
As determined during a meeting at the Element 84 offices (formerly Azavea offices) on 2023-05-24.
-
async
-first - Allow range requests
- Download functionality
- Update STAC items to point to new hrefs on download
- Allow byte-stream access
- Protocols:
- http
- s3
- requestor pays
- custom endpoint
- custom authentication
- Planetary Computer
- USGS EROS
- NASA
- Copy directly from source to destination ("skip local")
- Add new assets to an item
- Update an existing asset
- Delete assets
- Templated paths on download
- (possible) Support the file extension's local path
- Checksum validation and creation
- CLI
Contributing
Use Github issues to report bugs and request new features. Use Github pull requests to fix bugs and propose new features.
Developing
Clone, install with the dev dependencies, and install pre-commit:
git clone git@github.com:gadomski/stac-asset.git
cd stac-asset
pip install '.[dev]'
pre-commit install
Testing
All network-touching tests are disabled by default, because we can't use pytest-vcr (https://github.com/kevin1024/vcrpy/issues/597), and repeatedly hitting the network during testing and CI is bad behavior. To enable network-touching tests:
pytest --network-access
Some tests are client-specific and need your environment to be configured correctly. See each client's documentation for instructions on setting up your environment for each client. If your environment is not configured for a certain client, that client's tests are skipped.
Docs
Install the documentation dependencies:
pip install -e '.[docs]'
Then, build the docs:
make -C docs html && open docs/_build/html/index.html
It can be handy to use sphinx-autobuild if you're doing a lot of doc work:
pip install sphinx-autobuild
sphinx-autobuild docs docs/_build/html
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file stac-asset-0.0.1.tar.gz
.
File metadata
- Download URL: stac-asset-0.0.1.tar.gz
- Upload date:
- Size: 16.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b55a9d1a6a042acb50311014bc652f60dcdfed7da242082bacb22d8c6e81246 |
|
MD5 | efbfde4cf85d0900329dd4819d66c8c1 |
|
BLAKE2b-256 | eac5aaad652ebe1cc7d18720e0ad55e433eb417528dfff6662267497e152ead1 |
File details
Details for the file stac_asset-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: stac_asset-0.0.1-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bbe33b85fb3d85768ede99d59fb281da5bc4e553a93a9bb022e37ac203aa5fe |
|
MD5 | 83630728001bc289f3158e631cd07f09 |
|
BLAKE2b-256 | 31da5d4757843885dfea7647da164768b6b9cf94db077a0d4a4dacaac7a30bbd |