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.7.tar.gz (742.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.7-cp311-abi3-musllinux_1_2_x86_64.whl (35.3 MB view details)

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

rustac-0.9.7-cp311-abi3-musllinux_1_2_i686.whl (37.3 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

rustac-0.9.7-cp311-abi3-musllinux_1_2_armv7l.whl (32.7 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.9.7-cp311-abi3-musllinux_1_2_aarch64.whl (32.7 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.9.7-cp311-abi3-manylinux_2_28_x86_64.whl (29.4 MB view details)

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

rustac-0.9.7-cp311-abi3-manylinux_2_28_ppc64le.whl (32.7 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ppc64le

rustac-0.9.7-cp311-abi3-manylinux_2_28_armv7l.whl (25.1 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARMv7l

rustac-0.9.7-cp311-abi3-manylinux_2_28_aarch64.whl (26.1 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.9.7-cp311-abi3-macosx_11_0_arm64.whl (24.3 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.9.7-cp311-abi3-macosx_10_12_x86_64.whl (26.1 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rustac-0.9.7.tar.gz
Algorithm Hash digest
SHA256 36199f602dd65401156a47bc7bd3c3ca252eb56c14895bcd4a2e64d125980c29
MD5 e10d0ca85459ecf103cad64bcfbf6307
BLAKE2b-256 fd86f557b59bbfa54b681aa2f4d5a73063e92e543deaa265fd4c8c9d7dcacde7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.7-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4670efbad32c30cc94f8a943bf4288e40f6d12216b05f365c6f10c3d7c0b01e5
MD5 23edad88ab251e1f6bb4b551329ce8c5
BLAKE2b-256 a07a2632595a805437433b40b02ef9cdc3598621950ccb372ac59acda08acf26

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.7-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 1a61a86bb1feed8ff5aa659d8ecaa535eb0a4486e0265ebb3936486f63dd6263
MD5 af9a68a1627953d6ce2866ba1f9610f4
BLAKE2b-256 b31b362c20cb67245cbdf396188013a094f52188bca64dbb2c21c38b70f844ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.7-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 0b32380d7994bd06c69d5333cd0528f18d6967f13c2a40a958ed1f7701786629
MD5 4fd007b50d880d71e3cffd46111f71fd
BLAKE2b-256 e80a0724b111e77e066d950265bfe49eebb147dbca3d480bb73165d197ba2d40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.7-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 f510f28df674a6efbbda31543778df268bde9a5382a17bbbb7978b1e2fd10d92
MD5 ccc514fb749980e2538ec50855f08bff
BLAKE2b-256 28d4c2065d53a608b522db1cc8176d231036729ed6748040071860b7a6db281c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.7-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 61c6880a0812fb66fd96e5c68fac125814e910d0758e315c011d3a55cf1893fc
MD5 9dc8ecb444eca6a2628a21e37f10f1a2
BLAKE2b-256 c98a5c82440018dbddb849276e60896c915d9dc2856d2b9e73168f21ccb4217e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.7-cp311-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 58001af2e35713e42b3d6d2554097da2922d94ee64ea7f9545b450cc52e2807e
MD5 aa147906c2f851e241a8d2dc8ee9c9d7
BLAKE2b-256 b0688017248fe5c8134e2039143ecefa13efdcb416f2ee35a870954b0ffd24ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.7-cp311-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 32a0a650c72580ecfae44733e72c011458e5cf8f013616dfb3eb6eb223059b90
MD5 c3c51fefbc8f73f1d05537360355eb2c
BLAKE2b-256 0dd7cf2dc7190eb99e9002599cb792ace671fbf08e3869414dab6af080a8f20b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.7-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 54c4f371362f668641b35b6936603a54853393de14a0c0266d6678d5f0f859b4
MD5 111c2761c2f12b1a68195a82461bdd35
BLAKE2b-256 72ee242ba2fc2f4f54595e730ced3968753a8bb86618d648faafab0f4b124f50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.7-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e544267ce461b91fda5644b2821869b0042f8413134a36072cc569bca48e51e
MD5 e2ab85505ffcdf44f54fe2e1ba43d33e
BLAKE2b-256 6ccf578a52afce63396083042f1712e745e78dffb75888f8e01b1451acfe7a7d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.7-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f67facac6f18b313b460fc61189191605903a3005e5cbe5763840119d709183c
MD5 76098b22caf23190a76ff401f095ec08
BLAKE2b-256 943b285e5ea3c722d754259e4365c1c89268b0abcefd71dc0500ecd46e811eca

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