Skip to main content

Command line tool and Python library for working with STAC.

Project description

stactools

Build Status Documentation License

stactools is a command line tool and library for working with STAC based on PySTAC.

Installation

Installing the base package

> pip install stactools

From source repository:

> git clone https://github.com/stac-utils/stactools.git
> cd stactools
> pip install .

To install stactools with all subpackages, use:

> git clone https://github.com/stac-utils/stactools.git
> cd stactools
> pip install .[all]

Installing additional subpackages and plugins

stactools is composed of a namespace package with individual sub-packages installable on their own. This allows users to install only the parts of stactools that they need, and for new plugins with heavy dependencies to be developed without effecting the overall

> pip install stactools[all]

to install

> pip install stactools_planet
> pip install stactools[planet]
install command description
pip install stactools[all] Installs all available subpackages contained in the stac-tools repo
pip install stactools[planet] Installs the planet subpackage for working with planet data

Running

> stac --help

Documentation

See the documentation page for the latest docs.

Sub-packages

stactools is comprised of subpackages that provide library and CLI functionality. Below is a list of available subpackages.

subpackage description
stactools_core Contains core library functionality that is used across the other projects
stactools_cli Contains the command line interface (cli) for running the stactools command
stactools_aster Methods and commands for working with ASTER data
stactools_planet Methods and commands for working with planet data
stactools_landsat Methods and commands for working with landsat data (TODO)
stactools_browse Contains a command for launching stac-browser against a local STAC

Subpackages are symlinked to the stactools directory in this repo to allow them to be importable for python running at the top level directory of the repository clone.

Developing

Using docker

Some subpackages require environments with more complex environments than can be set up just through pip. For example, the stactools.aster package uses rasterio functionality that required a GDAL enabled with the HDF4 format. Because of this, it's recommended to utilize the docker environment provided by this repository.

Once the container is built, you can run the scripts/ scripts inside a docker console by running:

> docker/console

Using virtualenv

If not using docker, itt's recommended to use virtualenv to keep isolate the python environment used to develop stactools. See virtualenv documentation for more detailed information, but as a shortcut here's some quick steps:

  • Make sure virtualenv is installed
  • Run virtualenv venv
  • Activate the virtualenv with source venv/bin/active

Installing development requirements

To install all the requirements for subpackages and the development requirements, use:

> scripts/update

Note that some packages might fail requirement installs because of required environment setup that cannot be controlled with pip-install. For instance, you may need to install rasterio with a GDAL that has non-standard formats enabled. You can avoid errors by installing the proper environment, by installing the failing requirements like rasterio manually, or by using the docker environment.

Running the CLI against development code

You can run the CLI through docker by running

> docker/stac --help

or in the local environment with

> scripts/stac --help

Unit Tests

Unit tests are in the tests folder. To run unit tests, use unittest:

> python -m unittest discover tests

To run linters, code formatters, and test suites all together, use test:

> ./docker/test

or

> ./scripts/test

Code quality checks

stactools uses flake8 and yapf for code formatting and style checks.

To run the flake8 style checks:

> flake8 stactools_* tests

To format code:

> yapf -ipr stactools_* tests

To check for spelling mistakes in modified files:

> git diff --name-only | xargs codespell -I .codespellignore -f

You can also run the ./docker/test or ./scripts/test script to check for linting, spelling, and run unit tests.

Documentation

To build and serve the docs, all of the requirements must be installed with scripts/update. Make sure Pandocs is installed. Also make sure sphinx is available, which should be installed with requirements-dev.txt. You can also run the following in the docker container using

> docker/console

To build the docs, you can use make html, and to build the docs and start a server that watches for changes, use make livhtml:

> cd docs
> make html
> make livehtml

If using make livehtml, once the server starts, navigate to http://localhost:8000 to see the docs.

Use 'make' without arguments to see a list of available commands.

Adding a new sub-package

stactools is happy to take contributions of new subpackages for working with specific data types! Below is a list of steps to add a new subpackage:

  • Add the new subpackage as stactools_{pkg}, where {pkg} is a short name for the dataset the subpackage works with (e.g. "landsat")
  • Create a setup.py, requirements.txt, and README.md in the subpackage directory.
  • The code should exist in the stactools/{pkg}/ directory in that package subdirectory. Note that the stactools does not have an init.py (look at the other subpackages for examples).
  • Add the subpackage to the appropriate variables in scripts/env
  • Add the subpackage to the appropriate tables in the README.
  • Add documentation for the subpackage.
  • Add subpackage to .readthedocs.yml install

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

stactools-0.1.2.tar.gz (4.8 kB view hashes)

Uploaded Source

Built Distribution

stactools-0.1.2-py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 3

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