Skip to main content

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

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

stacrs

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 stacrs?

A: stacrs can

If you don't need those things, stacrs probably isn't for you — use pystac and its friend, pystac-client.

Usage

Install via pip:

# basic
python -m pip install stacrs

# support arrow tables
python -m pip install 'stacrs[arrow]'

Or via conda:

conda install conda-forge::stacrs

Then:

import stacrs

# Search a STAC API
items = await stacrs.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 = await stacrs.search_to_arrow(...)
data_frame = GeoDataFrame.from_arrow(table)
items = stacrs.from_arrow(data_frame.to_arrow())

# Write items to a stac-geoparquet file
await stacrs.write("items.parquet", items)

# Read items from a stac-geoparquet file as an item collection
item_collection = await stacrs.read("items.parquet")

# You can search geoparquet files using DuckDB
# If you want to search a file on s3, make sure to configure your AWS environment first
item_collection = await stacrs.search("s3://bucket/items.parquet", ...)

# Use `search_to` for better performance if you know you'll be writing the items
# to a file
await stacrs.search_to(
    "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,
)

See the documentation for details. In particular, our example notebook demonstrates some of the more interesting features.

CLI

stacrs comes with a CLI:

$ stacrs -h
stacrs: A command-line interface for the SpatioTemporal Asset Catalog (STAC)

Usage: stacrs [OPTIONS] <COMMAND>

Commands:
  translate  Translates STAC from one format to another
  search     Searches a STAC API or stac-geoparquet file
  serve      Serves a STAC API
  validate   Validates a STAC value
  help       Print this message or the help of the given subcommand(s)

Options:
  -i, --input-format <INPUT_FORMAT>
          The input format.
      --opt <OPTIONS>
          Options for getting and putting files from object storage.
  -o, --output-format <OUTPUT_FORMAT>
          The output format.
  -c, --compact-json <COMPACT_JSON>
          Whether to print compact JSON output [possible values: true, false]
      --parquet-compression <PARQUET_COMPRESSION>
          The parquet compression to use when writing stac-geoparquet.
  -h, --help
          Print help (see more with '--help')

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

stac-geoparquet

stacrs 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 stacrs 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/stacrs.git
cd stacrs
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

stacrs 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

stacrs-0.5.9.tar.gz (603.6 kB view details)

Uploaded Source

Built Distributions

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

stacrs-0.5.9-cp311-abi3-manylinux_2_28_aarch64.whl (20.8 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

stacrs-0.5.9-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.8 MB view details)

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

stacrs-0.5.9-cp311-abi3-macosx_11_0_arm64.whl (22.3 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

stacrs-0.5.9-cp311-abi3-macosx_10_12_x86_64.whl (21.0 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

stacrs-0.5.9-cp310-cp310-manylinux_2_28_aarch64.whl (20.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

stacrs-0.5.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

stacrs-0.5.9-cp310-cp310-macosx_11_0_arm64.whl (22.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

stacrs-0.5.9-cp310-cp310-macosx_10_12_x86_64.whl (21.0 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

Details for the file stacrs-0.5.9.tar.gz.

File metadata

  • Download URL: stacrs-0.5.9.tar.gz
  • Upload date:
  • Size: 603.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.8.2

File hashes

Hashes for stacrs-0.5.9.tar.gz
Algorithm Hash digest
SHA256 ddcfca4615d1ab71c79625499110f46961953e9b8c79e1366450f34d194b8a77
MD5 37ed2d7b150b2c06017ba389a73809fa
BLAKE2b-256 4812ad49dd6a31536dd9027f729184dc81be30867d0fe23dc3176ecb3ac8a98e

See more details on using hashes here.

File details

Details for the file stacrs-0.5.9-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for stacrs-0.5.9-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a3c5610a76d69b9baf200b3f9faaa8882f4fd3c11c66c1af71ac992d4df4941d
MD5 6e847e2e81bd59b63fe8b0a1d3d4a12f
BLAKE2b-256 e049fcc313d747e48992b13a2f7021fc35ea174db1bff14d273b5c0be8445745

See more details on using hashes here.

File details

Details for the file stacrs-0.5.9-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for stacrs-0.5.9-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 238c96a746d77cb35770dc002b6c7b1904ef874070e4300cf6643cb6adf98dec
MD5 b05bdd9101bd0bd78e80d3256fba5be2
BLAKE2b-256 84bd67efad6c19263dbc4f27b6f7db628b7aceda865ca969b50a3073651eb9b0

See more details on using hashes here.

File details

Details for the file stacrs-0.5.9-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for stacrs-0.5.9-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0c93b07048111a6480080db23cd5f5c89e67966dcd90cbee78dca15c1cc8ddb1
MD5 a8ed8b509d4399505e39d46910d82343
BLAKE2b-256 f076fb56297b57551adb58c731c7a7ee2eec9f4d12c22d81014e5443c1f0594e

See more details on using hashes here.

File details

Details for the file stacrs-0.5.9-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for stacrs-0.5.9-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0da7a1cd7c04bf29d054efd4e1a2258fc3c214f2cdacc934e512a3c4b6a8cc7c
MD5 9a84162ed7f1a7254f1eb9509f517cbc
BLAKE2b-256 21bd7494be14b748b313baec39242b14878a77a6684ad6b9857fc6c0605da6fd

See more details on using hashes here.

File details

Details for the file stacrs-0.5.9-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for stacrs-0.5.9-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6cce4a93e59ebe6f3222d65015853a13c8d5a5d9a5006872d34be29163f05423
MD5 bb2686bd63a77ad5f827e3a2f07593a2
BLAKE2b-256 506d172788f2a5742d0645a1e48b230f14a0e4ec46b3bcf1f2eab91210ca5baa

See more details on using hashes here.

File details

Details for the file stacrs-0.5.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for stacrs-0.5.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eac36df2826e2140e91e0365bb04c6461675aa654635c3f27663c01d7e03b112
MD5 2c990edf0b8e9f101335922a4a0867b1
BLAKE2b-256 1f4b5f3ed391e64d25426f4643f66cd05795b1068b20f6675fb7649b5778b9e2

See more details on using hashes here.

File details

Details for the file stacrs-0.5.9-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for stacrs-0.5.9-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 edfdff03574b887d018c7dd8a98aa267d68f2fa7ad9aa3206756847fd8c99da0
MD5 f46bfdc63f7a75c278951ec74b1813ea
BLAKE2b-256 c9c7561faf34afbe4e7ab8c0c1e376865aeb7ee4eabd3029a81eb1897c4a9301

See more details on using hashes here.

File details

Details for the file stacrs-0.5.9-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for stacrs-0.5.9-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 059ed79ac277c8de2fbd58e1b19d8ac2cb802fc1ec4fd42741b0fac8f7df887c
MD5 5716df56b095d5e4a8975e9dd30f5d3d
BLAKE2b-256 19ebb74b39f2a46f8254eb867bb1704ebd065aa48ae9db6bfcc61983a6b0f154

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