Skip to main content

A no-dependency Python package for STAC, using Rust under the hood.

Project description

rustac

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

A Python package for STAC using Rust under the hood.

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.

Usage

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

Then:

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.

CLI

rustac comes with a CLI:

rustac -h

[!NOTE] Before rustac v0.5.4, the CLI was its own PyPI package named stacrs-cli, which is no longer needed.

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.

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.6.0.tar.gz (374.0 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.6.0-cp311-abi3-manylinux_2_28_aarch64.whl (20.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.6.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.6 MB view details)

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

rustac-0.6.0-cp311-abi3-macosx_11_0_arm64.whl (18.7 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.6.0-cp311-abi3-macosx_10_12_x86_64.whl (20.6 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

rustac-0.6.0-cp310-cp310-manylinux_2_28_aarch64.whl (20.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

rustac-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

rustac-0.6.0-cp310-cp310-macosx_11_0_arm64.whl (18.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

rustac-0.6.0-cp310-cp310-macosx_10_12_x86_64.whl (20.6 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: rustac-0.6.0.tar.gz
  • Upload date:
  • Size: 374.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for rustac-0.6.0.tar.gz
Algorithm Hash digest
SHA256 1ba857408aff59ce5c1dfab052b2e94ab9cca14253778b8f9da15208887b16f6
MD5 d0fdd1eca6bb3a5d153d95deea6b88aa
BLAKE2b-256 3481b394d814d8327b1e47d8cbb614a6b35d759deafe5c36428a9537805edfaa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.6.0-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 200126f6f9a131e6aee8c812929f5e756fc00282e738dc2991e5b79539e9491d
MD5 ec93753c77e2255fccd264566640978d
BLAKE2b-256 262f42aa04841aafb82dfe9e6183264eaa18e01a5a89f82c252759ac09337bea

See more details on using hashes here.

File details

Details for the file rustac-0.6.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustac-0.6.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6c5c51e13747241364ec3faa7577a64da9a41587f369959d75711b1b99c06edd
MD5 53c2edc29271696ff5abb29d356942bf
BLAKE2b-256 9f8fd55a44fc661d3aefe96b3a55fa5da40f2985294717f43d3569891d643732

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.6.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b176287dc4379a6d3de0adfac3234498f540caba5cb51fa7848be59dc3b7d625
MD5 c64ee746ffa1bb887d62fe521bf457fe
BLAKE2b-256 a8856cd69880454976223f22825dc0e28589a511ff1b48a110b3b1edf9872f74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.6.0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 23f916232de914cc8f80e0bcac97d3aa7f145fdc82fe4ab5f5c6b7c716b5764f
MD5 52a280514968cbcebda73e115f67f8aa
BLAKE2b-256 9d90f56298afb15a71ca22f4e6eb398f9ce9104007df9951fbe9adf513bea9c5

See more details on using hashes here.

File details

Details for the file rustac-0.6.0-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rustac-0.6.0-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ae856c14820d893ad47533e174c4848edd7cf23c69fdc9eeb5d94d51d19edd57
MD5 576c4bd1c0690f0cff9a2f9506c9f02e
BLAKE2b-256 e3e61d0d7c5dd1d2f1664ca4270e4739b0b24b0463a68e490047002e690fadbb

See more details on using hashes here.

File details

Details for the file rustac-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustac-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8b5d6f5ffa457ec865d519c1cda8afdbb8d714eed7cf9e8026a2041ea0b90ae6
MD5 32292f0a3e2a71258fee288579cb7a22
BLAKE2b-256 0bcfb40070fd76825666bf927a89c42ea6f7ef409c9edae9371ab87a1e4434da

See more details on using hashes here.

File details

Details for the file rustac-0.6.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rustac-0.6.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 16944b67812c08d34548d0f3ec0200e0b4b9790e2e1e14c7187ae7de490e6097
MD5 c9c89d253b2356875810531006192510
BLAKE2b-256 e2c2921ac2060649bf248c332e374f8db6faa7097ba8775fc38a31cabd3f1237

See more details on using hashes here.

File details

Details for the file rustac-0.6.0-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rustac-0.6.0-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7dcedf84d053d22f3689893772216deef456f3a8576a2901542c84e51c5a37ea
MD5 cd40eb8c7af2f78ed226b9d5ab8426eb
BLAKE2b-256 900d08e9ac0d7d89f7a0a0edda4b8c0ff1419b73b77c583e1fe270394197de79

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