Skip to main content

The power of Rust for the Python STAC ecosystem

Project description

rustac

GitHub Workflow Status GitHub Workflow Status PyPI - Version Conda forge PyPI - License Contributor Covenant

The rustac logo

The power of Rust for the Python STAC ecosystem.

[!TIP] We pronounce rustac "ruh-stac".

[!NOTE] Until 2025-04-17, this package was named stacrs. See this RFC for context on the name change.

Why?

Q: We already have PySTAC, so why rustac?

A: rustac can

If you don't need those things, rustac probably isn't for you — use pystac and its friend, pystac-client.

Installation

rustac has zero required dependencies. Install via pip:

# basic
python -m pip install rustac

# support arrow tables
python -m pip install 'rustac[arrow]'

Or via conda:

conda install conda-forge::rustac

From source

You'll need Rust. By default, rustac wants to find DuckDB on your system:

brew install duckdb  # if you're using Homebrew ... if not, get DuckDB another way
python -m pip install -U git+https://github.com/stac-utils/rustac-py

If you don't want to (or can't) install DuckDB, can build DuckDB as a "bundled" build (warning: it takes a while):

MATURIN_PEP517_ARGS="--features=duckdb-bundled" python -m pip install -U git+https://github.com/stac-utils/rustac-py

Usage

import asyncio
import rustac

async def main() -> None:
    # Search a STAC API
    items = await rustac.search(
        "https://landsatlook.usgs.gov/stac-server",
        collections="landsat-c2l2-sr",
        intersects={"type": "Point", "coordinates": [-105.119, 40.173]},
        sortby="-properties.datetime",
        max_items=100,
    )

    # If you installed with `pystac[arrow]`:
    from geopandas import GeoDataFrame

    table = rustac.to_arrow(items)
    data_frame = GeoDataFrame.from_arrow(table)
    items = rustac.from_arrow(data_frame.to_arrow())

    # Write items to a stac-geoparquet file
    await rustac.write("/tmp/items.parquet", items)

    # Read items from a stac-geoparquet file as an item collection
    item_collection = await rustac.read("/tmp/items.parquet")

    # Use `search_to` for better performance if you know you'll be writing the items
    # to a file
    await rustac.search_to(
        "/tmp/items.parquet",
        "https://landsatlook.usgs.gov/stac-server",
        collections="landsat-c2l2-sr",
        intersects={"type": "Point", "coordinates": [-105.119, 40.173]},
        sortby="-properties.datetime",
        max_items=100,
    )

asyncio.run(main())

See the documentation for details. In particular, our examples demonstrate some of the more interesting features.

Command line interface (CLI)

rustac comes with a CLI:

rustac -h

stac-geoparquet

rustac replicates much of the behavior in the stac-geoparquet library, and even uses some of the same Rust dependencies. We believe there are a couple of issues with stac-geoparquet that make rustac a worthy replacement:

  • The stac-geoparquet repo includes Python dependencies
  • It doesn't have a nice one-shot API for reading and writing
  • It includes some leftover code and logic from its genesis as a tool for the Microsoft Planetary Computer

We test to ensure compatibility between the two libraries, and we intend to consolidate to a single "stac-geoparquet" library at some point in the future.

Development

Get Rust, uv, and (optionally) libduckdb. Then:

git clone git@github.com:stac-utils/rustac-py.git
cd rustac-py
scripts/test

See CONTRIBUTING.md for more information about contributing to this project.

DuckDB

By default, this package expects libduckdb to be present on your system. If you get this sort of error when building:

  = note: ld: library 'duckdb' not found

Set your DUCKDB_LIB_DIR to point to your libduckdb. If you're using homebrew, that might look like this:

export DUCKDB_LIB_DIR=/opt/homebrew/lib

Alternatively, you can use the duckdb-bundled feature to build DuckDB bindings into the Rust library:

maturin dev --uv -F duckdb-bundled && pytest

[!WARNING] Building DuckDB bundled takes a long while.

Docs

If you want to run an off-cycle docs update (e.g. if you fixed something and want to post it without having to make a new release):

mike deploy [version] latest --push

Acknowledgements

We'd like to thank @jkeifer, @parksjr, and @Xenocide122 (all from @Element84) for creating the rustac logo from an AI-generated image from this prompt:

There is a library for working with STAC metadata that is written in rust called rustac: https://github.com/stac-utils/rustac. That name sounds like the word "rustic", and is meant to envoke (sic) an image of "a cabin and a glass of neat whisky".

License

rustac-py is dual-licensed under both the MIT license and the Apache license (Version 2.0). See LICENSE-APACHE and LICENSE-MIT for details.

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

rustac-0.9.15.tar.gz (457.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rustac-0.9.15-cp311-abi3-win_amd64.whl (26.5 MB view details)

Uploaded CPython 3.11+Windows x86-64

rustac-0.9.15-cp311-abi3-win32.whl (23.8 MB view details)

Uploaded CPython 3.11+Windows x86

rustac-0.9.15-cp311-abi3-musllinux_1_2_x86_64.whl (37.3 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ x86-64

rustac-0.9.15-cp311-abi3-musllinux_1_2_i686.whl (39.5 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

rustac-0.9.15-cp311-abi3-musllinux_1_2_armv7l.whl (34.5 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.9.15-cp311-abi3-musllinux_1_2_aarch64.whl (34.6 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.9.15-cp311-abi3-manylinux_2_28_x86_64.whl (31.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ x86-64

rustac-0.9.15-cp311-abi3-manylinux_2_28_ppc64le.whl (34.7 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ppc64le

rustac-0.9.15-cp311-abi3-manylinux_2_28_armv7l.whl (26.8 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARMv7l

rustac-0.9.15-cp311-abi3-manylinux_2_28_aarch64.whl (28.1 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.9.15-cp311-abi3-macosx_11_0_arm64.whl (26.2 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.9.15-cp311-abi3-macosx_10_12_x86_64.whl (28.0 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file rustac-0.9.15.tar.gz.

File metadata

  • Download URL: rustac-0.9.15.tar.gz
  • Upload date:
  • Size: 457.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for rustac-0.9.15.tar.gz
Algorithm Hash digest
SHA256 49afae9c3014eeb6e8ddc8bec834e6b19a4a52abdefdac583e413b386ac6e721
MD5 0f7b9adfba327bef12e1bc7a538346a1
BLAKE2b-256 8e206843c30ed7281ca0210dbdc0d4e502118c1a7988ac28f2ee18857b96a501

See more details on using hashes here.

File details

Details for the file rustac-0.9.15-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: rustac-0.9.15-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 26.5 MB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for rustac-0.9.15-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0339dbafc8ce331befa084630b50e6f37e4062a97d178e6348a74435a0bf4166
MD5 2fa6520b2fa0d36b3ff3c9bbc7df506f
BLAKE2b-256 71357ff0a330d71d90cb165b616b25e1e6a69ae65d152319a7e1116196e6ea9e

See more details on using hashes here.

File details

Details for the file rustac-0.9.15-cp311-abi3-win32.whl.

File metadata

  • Download URL: rustac-0.9.15-cp311-abi3-win32.whl
  • Upload date:
  • Size: 23.8 MB
  • Tags: CPython 3.11+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for rustac-0.9.15-cp311-abi3-win32.whl
Algorithm Hash digest
SHA256 254789c71fe8a4a324b293965819acfa068d57d3b8dcd5f2fef14d27d311278b
MD5 debae14060dd02bed410053ea0f8e043
BLAKE2b-256 10853d14cbf8d8c70ac3d7a442698628bdc41ab9032190840c1130764a85609f

See more details on using hashes here.

File details

Details for the file rustac-0.9.15-cp311-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for rustac-0.9.15-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2db052e1e0b043fc8a2041d258170c986e35a04d34bc4c4b1e473b6826e8c854
MD5 111a3e1489db54f46e8189b834cf58f2
BLAKE2b-256 6b9abd96cb1f3f37c88051f2af08d5ff6ff6d6509b7d3d012fdfefc0f9f4dd27

See more details on using hashes here.

File details

Details for the file rustac-0.9.15-cp311-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for rustac-0.9.15-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 180f1771c6c1b00a15c23959cb8dee2f0e84a02f8d09048d1f58b53ca94797ea
MD5 e85ce89a3786aecb2c3f7660fba51f6c
BLAKE2b-256 3cdc4caf761c2918396273bdc15c41cbdfaa3d6e867e7ee18fa6a32cd09a9944

See more details on using hashes here.

File details

Details for the file rustac-0.9.15-cp311-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for rustac-0.9.15-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 6f7a85d57426e239f4e55470b50c3c2769ee30787252f92110e26f88113cb6aa
MD5 052113d9e1bea38ad5d46cdb7756b9c8
BLAKE2b-256 6301daf2a098afdf6e0cf904a0e89452d4e242ccf535196912f80c0b3ca3f40b

See more details on using hashes here.

File details

Details for the file rustac-0.9.15-cp311-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for rustac-0.9.15-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 5ed4a5eb8a2ab299adf5ad1b8c68789545f20b83634c045b5e3a1b50bdc37db8
MD5 540244d403af1f3fc781800f32c54cc4
BLAKE2b-256 2a8fbc7474cb1d1ccf1b279ccabba9bc456fef3f3a9e353da6c31ac949e937fb

See more details on using hashes here.

File details

Details for the file rustac-0.9.15-cp311-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rustac-0.9.15-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 95d444cccb70a0bc32c59cfeb0969cafe316ba67b6249a8a0107b4feaca581c2
MD5 7bd3605c0ac18ad5be87ee69994ec1d9
BLAKE2b-256 9310a0127155a81d4a3e92630dc61dd20211f4323b7ffdf3c223d852bbc110fe

See more details on using hashes here.

File details

Details for the file rustac-0.9.15-cp311-abi3-manylinux_2_28_ppc64le.whl.

File metadata

File hashes

Hashes for rustac-0.9.15-cp311-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 a071758f9ab9634c7c7ee3c8b34644ead2b18bc22bbb7d6dc05e1c187c95f6f7
MD5 6463a170ecaa9d69f9ae2a90e20b8ddc
BLAKE2b-256 13d6c5544d9cbc14aba021af48b5f3c564d79e4dbd19519260a20156590ed2cd

See more details on using hashes here.

File details

Details for the file rustac-0.9.15-cp311-abi3-manylinux_2_28_armv7l.whl.

File metadata

File hashes

Hashes for rustac-0.9.15-cp311-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 5f234888fd2c25f2cdb98fbff830e6b2147cc2030d3501e3d45f6ee1e96a3469
MD5 dc193719a71efb687ee652f047f4105c
BLAKE2b-256 1d3a8f5a5ff66f18cad83797761cee027088194bf018085279b531150631a3b9

See more details on using hashes here.

File details

Details for the file rustac-0.9.15-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rustac-0.9.15-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e591454d7ba5d2c100b8c6a8ae0420bb8e2e536dc3f3d212b152f1f65157a021
MD5 e3fb7dcce8c601ce3e332e7b03ac0549
BLAKE2b-256 e641c7823d9be2f581f56c36bcc9fae425f5f221e4999a32bdb36a809f6942d3

See more details on using hashes here.

File details

Details for the file rustac-0.9.15-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rustac-0.9.15-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 da485f3f2d73aa56828a7e53b6aff04340da77d133f6c8d02d901bbe59700db3
MD5 32da9dfa96a12661ebc02eab832d2ea5
BLAKE2b-256 f6515663271db4f85cae17df8b90484c12c04b7923799d080c806469e37a03e7

See more details on using hashes here.

File details

Details for the file rustac-0.9.15-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rustac-0.9.15-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4aaaee59709472ba564e9a81dd844b71fc4c5059a545438d15772bd7dd507e9d
MD5 8f5ff8d4e939f9b443f3e4dacfaa953a
BLAKE2b-256 e9a9aa8550b425b4e79021e83d0402a5b6c667d8793af92ccb376627134c8c4f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page