Skip to content

Command line — pyramids cog#

pyramids ships a small command-line interface (the pyramids console script, registered on pip install pyramids-gis) built on the standard-library argparse — no extra dependency. The cog command group mirrors the common write / validate / inspect workflow.

# Write a COG (validates the output unless --no-validate)
pyramids cog create input.tif scene_cog.tif --profile zstd
pyramids cog create input.tif scene_cog.tif --compress DEFLATE --blocksize 256

# Validate (exit code 1 for a non-COG; --strict promotes warnings to errors)
pyramids cog validate scene_cog.tif --strict

# Print structured metadata + the overview pyramid
pyramids cog info scene_cog.tif

The functions are also callable in-process for scripting/testing:

from pyramids.cli import main
exit_code = main(["cog", "info", "scene_cog.tif"])

API#

pyramids.cli #

Command-line interface for pyramids — currently the cog command group.

Exposes the common Cloud Optimized GeoTIFF workflow from the shell, built on the pyramids COG engine and the standard-library :mod:argparse (no extra dependency):

  • pyramids cog create IN OUT [--profile P] [--compress C] [--blocksize N]
  • pyramids cog validate FILE [--strict]
  • pyramids cog info FILE

The entry point is registered as the pyramids console script; the functions here are also callable in-process (main([...])) for testing.

main(argv=None) #

Entry point for the pyramids console script.

Parameters:

Name Type Description Default
argv Sequence[str] | None

Argument list (excluding the program name). Defaults to :data:sys.argv when None.

None

Returns:

Name Type Description
int int

Process exit code (0 success, non-zero failure).

Examples:

  • Inspect a COG from the shell:
    >>> main(["cog", "info", "scene.tif"])  # doctest: +SKIP
    0
    
Source code in src/pyramids/cli.py
def main(argv: Sequence[str] | None = None) -> int:
    """Entry point for the `pyramids` console script.

    Args:
        argv: Argument list (excluding the program name). Defaults to
            :data:`sys.argv` when `None`.

    Returns:
        int: Process exit code (`0` success, non-zero failure).

    Examples:
        - Inspect a COG from the shell:
            ```python
            >>> main(["cog", "info", "scene.tif"])  # doctest: +SKIP
            0

            ```
    """
    parser = _build_parser()
    args = parser.parse_args(argv)
    return args.func(args)