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.12.tar.gz (748.4 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.12-cp311-abi3-win_amd64.whl (26.5 MB view details)

Uploaded CPython 3.11+Windows x86-64

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

Uploaded CPython 3.11+Windows x86

rustac-0.9.12-cp311-abi3-musllinux_1_2_x86_64.whl (37.2 MB view details)

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

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

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

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

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.9.12-cp311-abi3-musllinux_1_2_aarch64.whl (34.5 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.9.12-cp311-abi3-manylinux_2_28_x86_64.whl (31.4 MB view details)

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

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

Uploaded CPython 3.11+manylinux: glibc 2.28+ ppc64le

rustac-0.9.12-cp311-abi3-manylinux_2_28_armv7l.whl (26.7 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARMv7l

rustac-0.9.12-cp311-abi3-manylinux_2_28_aarch64.whl (28.0 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.9.12-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.12.tar.gz.

File metadata

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

File hashes

Hashes for rustac-0.9.12.tar.gz
Algorithm Hash digest
SHA256 9594c4ffb4f1a62606d75fd3a31b002eb4e5a98e1160871f5aa6b2d16791a14b
MD5 eea57feb8cf6e9911429d5cc0480729f
BLAKE2b-256 3352dc995b3a58415355a0cbf0124198c17d35b712d214de16d93428fa06e13f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rustac-0.9.12-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.12-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e2f037f04aab87be3a2833fa0aabf423cad5805a205f8ad111b16b42cfcba94d
MD5 6546a3373caa25549500c26bc1210ba4
BLAKE2b-256 d5d8d5282bbc8aef280da9865bb41ca3fb861a4c05ec0f5849bd027de848f201

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rustac-0.9.12-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.12-cp311-abi3-win32.whl
Algorithm Hash digest
SHA256 ffb552897b4ff97c889b354282e09ea5d9d0a790b2ae28787e5641ad29c7a3d1
MD5 d0845c3836f1b5ffa96d15503e5f02f2
BLAKE2b-256 bff42a9ddf59b9755daad0106b819071049f8c8ae98856a6f204d3bc04db9bae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.12-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ac6ac3fe160eb03f7defc85aecdeb23e8f4a9d77d1d16437a25b44d257a7809e
MD5 24e5d017d0d6bb3a79479b75781acb30
BLAKE2b-256 c7dc5e83b27cc35c2cd5fd7e8a0723cd4e3f6c4667f29bce797e7b8f411a7c2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.12-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 e8ceef0bf3bb6aefe9c23f0e06d974c187a969f32ae5adf22bd141dbeaef74f9
MD5 010a55f9b6c886a3bf1794e24c924e53
BLAKE2b-256 f64ce7e0601a3cbf86a3c57fa6b7d85a5911d8e72a6c99d12a659492c894228a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.12-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 dad90814f9786a60336a6191f3650ccfa67f492b9a4d9043d7a4f9dedf95811c
MD5 52c97b29e3a8ea5042c9e5cfe42bea85
BLAKE2b-256 c041898f93096f009ddfa96af840dec7f585f5b3f082e7d54dd60cbd5305711a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.12-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 08f918f841af7bccc33e60399c208c2951845bfa5ede85c2cfb2e409c3301767
MD5 08d493922bb2195b89b4138984b98779
BLAKE2b-256 adce08c29c7b2ee5f4835601c1bcf2f1914190af176192dd9483b50fdc5d9e88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.12-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7ea0be178d14fba2b71fbf61c4c652c3312bd84b744e4a890449b8191f9aa6d7
MD5 186e9c6125bb371e0c6fe3e2647838ce
BLAKE2b-256 9564d3e8713d956b7461299a12bc2bdfd45753ac72dbb012e913952af1084687

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.12-cp311-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 d4fbebffac42ad5c29077d712d0cac59660074d46cc7bed6f5f3b1cfd96fc115
MD5 e8366a799eeee5401e8b5df5fe2ef8b0
BLAKE2b-256 323097ac9a2cb86c200d37ab25db39dd36929bc7281122c8e651060f95c1ca47

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.12-cp311-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 975ec3492b2897fb32a87a82194373c09c3a8ab5d374794c8fafe84769b1117f
MD5 3af22e18cbca8d79d4b43afef2e90940
BLAKE2b-256 6c9cab28570cbea05a03003d9c01ae9f753820bdc678258e9d8f5d5c1f025d84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.12-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1b1cec41404325dca3d110a4575df69c7ac51ac899a867d8fb61bbf4b4a51fe6
MD5 40eb0b73d6ed3215cbfec9b639e1e228
BLAKE2b-256 379dfe21320dbb03b9b3f1b0d580abf688641c29dddd351ea5edc1fab1938572

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.12-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e8e1e1560cce904a2f2642576aa1a0040b69886b26da78277efa423484ed8acf
MD5 1717848b200609dbbdf864f45ba6c254
BLAKE2b-256 19ce80cf077399fbed998ca40df744432d1d6edc0e75ed8d1ab18e0faedb7323

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.12-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5bc5340561e2e94cc3c5fcc528dbde03cf02ac6cbb3a9a3640df1e6195c2f100
MD5 e134595b4aa15e7cd3d5a4859a44add7
BLAKE2b-256 dc44fc1983de8e5424a4a94fb62462b667bf1bdca396dee90b8c5116319b2d98

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