Skip to main content

Dynamically create image chips from STAC items

Project description

stacchip

Dynamically create image chips for earth observation machine learning applications using a custom chip index based on STAC items.

Get a STAC item, index its contents, and create chips dynamically like so

# Get item from an existing STAC catalog
item = stac.search(...)

# Index all chips that could be derived from the STAC item
index = Indexer(item).create_index()

# Use the index to get RGB array for a specific chip
chip = Chipper(index).chip(x=23, y=42)

Motivation

Remote sensing imagery is typically distributed in large files (scenes) that typically have the order of 10 thousand of pixels in both the x and y directions. This is true for systems like Landsat, Sentinel 1 and 2, and aerial imagery such as NAIP.

Machine learning models operate on much smaller image sizes. Many use 256x256 pixels, and the largest inputs are in the range of 1000 pixels.

This poses a challenge to modelers, as they have to cut the larger scenes into pieces before passing them to their models. The smaller image snippets are typically referred to as "chips". A term we will use throughout this documentation.

Creating imagery chips tends to be a tedious and slow process, and it is specific for each model. Models will have different requirements on image sizes, datatypes, and the spectral bands to include. A set of chips that works for one model might be useless for the next.

Systemizing how chips are tracked, and making the chip creation more dynamic is a way to work around these difficulties. This is the goal fo stacchip. It presents an approach that leverages cloud optimized technology to make chipping simpler, faster, and less static.

Overview

Stacchip relies on three cloud oriented technologies. Cloud Optimized Geotiffs (COG), Spatio Temporal Asset Catalogs (STAC), and GeoParquet. Instead of pre-creating millions of files of a fixed size, chips are indexed first in tables, and then created dynamically from the index files when needed. The imagery data itsel is kept in its original format and referenced in STAC items.

Creating chips with stacchip is composed of two steps:

  1. Create a stacchip index from a set of STAC
  2. Dynamically create pixel arrays for any chip in the stacchip index

Indexes can be created separately for different imagery sources, and combined into larger indexes when needed. This makes mixing different imagery sources simple, and allows for flexibility during the modeling process, as imagery sources can be added and removed by only updating the combined index.

The mechanism is purposefully kept as generic as possible. The index creation is done based on a STAC item alone, no other input is needed. Obtaining image data for a chip that is registered in a stacchip index only requires a few lines of code.

For more information, please consult the documentation

Build and release

The following steps to release the latest version

python -m build
python3 -m twine upload --repository testpypi dist/*
python3 -m twine upload --repository pypi dist/*

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

stacchip-0.1.33.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

stacchip-0.1.33-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file stacchip-0.1.33.tar.gz.

File metadata

  • Download URL: stacchip-0.1.33.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.6

File hashes

Hashes for stacchip-0.1.33.tar.gz
Algorithm Hash digest
SHA256 e53d4b5171b564c705e0ebf8f5ada1c4b9d78b93be18287bb42419057029b31b
MD5 a06ce19774ad61fef3c672069d5787f1
BLAKE2b-256 8cf01db7ccbbcbaea8ee2c9e36b65f96454d5a33a8791582648e956d85e1559e

See more details on using hashes here.

File details

Details for the file stacchip-0.1.33-py3-none-any.whl.

File metadata

  • Download URL: stacchip-0.1.33-py3-none-any.whl
  • Upload date:
  • Size: 25.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.6

File hashes

Hashes for stacchip-0.1.33-py3-none-any.whl
Algorithm Hash digest
SHA256 5756250e03b5661ae27daa8821e0bb9ae7304d61cb459d9145dcad54f35c43e5
MD5 b67c341093e721f1d48491c47d80a591
BLAKE2b-256 d18bdccaae86dbb326007cf9d64246767b2bdccab03594894d9061624bae9dc2

See more details on using hashes here.

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