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

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

rustac-0.9.0-cp311-abi3-musllinux_1_2_i686.whl (37.4 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

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

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.9.0-cp311-abi3-musllinux_1_2_aarch64.whl (33.2 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.9.0-cp311-abi3-manylinux_2_28_x86_64.whl (29.6 MB view details)

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

rustac-0.9.0-cp311-abi3-manylinux_2_28_ppc64le.whl (32.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ppc64le

rustac-0.9.0-cp311-abi3-manylinux_2_28_armv7l.whl (25.3 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARMv7l

rustac-0.9.0-cp311-abi3-manylinux_2_28_aarch64.whl (26.7 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.9.0-cp311-abi3-macosx_11_0_arm64.whl (22.6 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.9.0-cp311-abi3-macosx_10_12_x86_64.whl (24.7 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rustac-0.9.0.tar.gz
Algorithm Hash digest
SHA256 1dd35ea459bbf4b67cb47112d2c6325f421a54c87fa51948d28227b3e7fdf960
MD5 5da4725234673bce84507c8aeb682f7c
BLAKE2b-256 ff0caae1d5a6f310d12758479f5362a4277338c7891de87adf734a3e0d18762f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.0-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2cce72ad0347acbdbe3851125323445e93be757bfea8468c5dc59e833b816cc9
MD5 545411d0e94fc33f80d053cf73439be7
BLAKE2b-256 d7f62bb33eb71fd50cfc69c4dea8a1f8ee4ffbd94665316861cb1b388ae0b0d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.0-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 391c1aec8a381ce29a3da794f1c99e6e0ea5e881a7b62e3665116e3c04c79abf
MD5 a8b37c80fe3a7ab1cb5558b221662b83
BLAKE2b-256 57d2f6f53058d335843b931672061dd24dcff2b058600573dc2c27d041238eaa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.0-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 85684d193d038a80900519a18892b034d6186da4c0f50bfbef4e408871b25711
MD5 9d24b4f062b8064de564775e2565d660
BLAKE2b-256 70c55d766ec76ac542c0d1a9be722c257ecd83871a51e0b8bcf112198cbed03e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.0-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 4eb20cf125803d79539572a25d44890014221dd2c620eda25a7623d5d41cf06c
MD5 186579599e871d55438ef69f101b8826
BLAKE2b-256 556955f47f643bff56c5ca2b3738ae873992d302f3018bb4974ac015a3883074

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.0-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d34df97a6987a71904d2753a5893b5d30e0594cd134bcaa2572ce33b635ced94
MD5 02600d65503ee79e7a8d20cbe535345f
BLAKE2b-256 893cd8d05a2512bd1058ebdab7261d7dcc818e16dc2af8ebbf9db5dec9e037f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.0-cp311-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 dbd1f6f142d5fa7ab469c9c7d0b73a1861126407cb5bbbea2a33441fb82c442c
MD5 35c523a25bddedf8ab5afac38982b046
BLAKE2b-256 89b6b2395088c866f8e484150aa111d840ee80e244b61dc4e95f35602a548285

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.0-cp311-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 a66e7fcf3266b8cbfb75c383bad09b27869687dee72dd33323437846c891e7b2
MD5 098b50ebad439a27241c4d3124c7277b
BLAKE2b-256 d0065dbe3fedb323569ff6869c0a56978a685a88c0e5bb95d433a976fab5e8c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.0-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b6bcea4183239f57dfee15957a0631c73c72998868b46dce036b3a1cdfc23ae4
MD5 55336120194f3d969a424541ea51f908
BLAKE2b-256 349eb34af6264ba12f9ea24399375516d30a6028be94f5c803705f76af2b919f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 21c5c4112794bb076ecbc9ed0ab04f2dc965e7342322da150989fe8d8f5ddb0c
MD5 fe871b4f6b98c0191b808b6db424e29a
BLAKE2b-256 c229f8e6f5924bb6c111618086b0009f0e1cc88b96e8521c625baa66d21a7048

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 75cc3cd8356fca15f4a04b3dd63cf5ae7d308e8123d8065a69b1d7d3e467fe93
MD5 5ef635c86dd63fcdf1664e493a7482cb
BLAKE2b-256 019f3cbbea75e85723a29a0362f2a41219b5078cb28e81b8b32fe22602679005

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