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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

rustac-0.6.0rc0-cp311-abi3-manylinux_2_28_aarch64.whl (20.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.6.0rc0-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.0rc0-cp311-abi3-macosx_11_0_arm64.whl (18.7 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.6.0rc0-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.0rc0-cp310-cp310-manylinux_2_28_aarch64.whl (20.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

rustac-0.6.0rc0-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.0rc0-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rustac-0.6.0rc0-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1a68cfcd8bf85444601f06653205021b5d60cda925ccec4f9367bb85ec31c93d
MD5 ec8fb90b95733ab40dcb57a89cdabb88
BLAKE2b-256 46ccfa91982ef007e1d1b782922d1685c0612a64b25e7bc0b954bafa883e4856

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.6.0rc0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 54c8023e9c5c460465e43ae547a748e8a8b0b56085a1ba1f096f3b7c8120348e
MD5 496de1ab950490906b86983224ab1b98
BLAKE2b-256 03f7f3a0ba2a38236e77cf13ebf70f9e881482f183768aae6b9fd58c4f773f08

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.6.0rc0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5301437afcebb3e0961a774f12d3a856d682fdbecfbf36287b75fb6f1d604f93
MD5 e085979717a359ba1378c86c06e658ac
BLAKE2b-256 aa5459840a34a7236f8a998ed5819c7765b7f037cbd3ea373a4a4fcccd471e67

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.6.0rc0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5360c8e742ec0f053ded2825a9f842885c844f4e0e170b871584993889ce2016
MD5 ecdde6e9ea8103af5cf4a8fb3806b17c
BLAKE2b-256 1136bb0a2c1516b4a260e055f0582e06bd8c528ebfd85ce74789fc7dab7ef48b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.6.0rc0-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 28e8679704986383df4e3140fe70b999e6f93d4b1b5cb8a0a4674abd459e1155
MD5 da5d97ae384e61087cc6528f4f12b6d3
BLAKE2b-256 ca0578dc47dc0c2ae99dabe2386a91dbf2fd8a027b47fa54f925f51a1c628ad0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.6.0rc0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 85fc4c7a53370ab7746498bc97fb9258896119ad2e8216ab8cc302ee6223f8b3
MD5 a75e9d509d316b997cf1a72916a9765d
BLAKE2b-256 739894ebe1e3bfb4d571871445fae502af869b5779e6b26627e94a57abbfacff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.6.0rc0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 191cb38d5ce627605c982c3d04ff191b5a8933113e8d2537771ee7f09c29e070
MD5 666440d2856b569f4c830a5d084a0e31
BLAKE2b-256 0830c3a1a5636da4f7e6bf5baa3b62e464106a469d1edc7df714014bd81cedc1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.6.0rc0-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a65190e398e6a2cae66924a987fc55a301c7d646e08cc348537befe8b208c2fb
MD5 11dcb7a7dee7b4d563ad1d2b4592f6da
BLAKE2b-256 0e55e46b4cf54163028c8694a4f34700929a35e9ac5f21aec0e2903bc2fcf11d

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