Skip to main content

Python bindings for the rstar R*-tree spatial index

Project description

rstar-python

Python bindings for the rstar R*-tree spatial index library.

Installation

pip install rstar-python

Usage

from rstar_python import PyRTree

# Create a 3D R-tree
tree = PyRTree(dims=3)

# Insert points
tree.insert([1.0, 2.0, 3.0])
tree.insert([4.0, 5.0, 6.0])

# Bulk load points
points = [
    [1.0, 2.0, 3.0],
    [4.0, 5.0, 6.0],
    [7.0, 8.0, 9.0]
]
tree.bulk_load(points)

# Find nearest neighbor
nearest = tree.nearest_neighbor([1.1, 2.1, 3.1])

# Find k nearest neighbors
k_nearest = tree.k_nearest_neighbors([1.1, 2.1, 3.1], k=2)

# Find neighbors within radius
neighbors = tree.neighbors_within_radius([1.0, 2.0, 3.0], radius=1.0)

# Query points within a bounding box
points = tree.locate_in_envelope(
    min_corner=[0.0, 0.0, 0.0],
    max_corner=[2.0, 2.0, 2.0]
)

# Get tree size
size = tree.size()

# Remove a point
tree.remove([1.0, 2.0, 3.0])

Features

  • Supports 1D to 4D points
  • Fast nearest neighbor queries
  • Radius search
  • Bounding box queries
  • Bulk loading for faster initialization
  • Built on top of the fast Rust rstar library

Development

Requirements:

  • Rust
  • Python 3.7+
  • maturin
# Clone repository
git clone https://github.com/kephale/rstar-python
cd rstar-python

# Create virtual environment
python -m venv venv
source venv/bin/activate  # or `venv\Scripts\activate` on Windows

# Install development dependencies
pip install maturin pytest

# Build and install in development mode
maturin develop

# Run tests
pytest

License

This project is licensed under the MIT License - see the LICENSE file 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.

rstar_python-0.0.1-cp311-cp311-win_amd64.whl (260.4 kB view details)

Uploaded CPython 3.11Windows x86-64

rstar_python-0.0.1-cp311-cp311-macosx_10_12_x86_64.whl (383.3 kB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

rstar_python-0.0.1-cp310-cp310-win_amd64.whl (260.4 kB view details)

Uploaded CPython 3.10Windows x86-64

rstar_python-0.0.1-cp310-cp310-macosx_10_12_x86_64.whl (383.3 kB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

rstar_python-0.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (411.3 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

File details

Details for the file rstar_python-0.0.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for rstar_python-0.0.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d9c5d822940ea263bb3223a60a866fdac814f58b62ac6e56838caab95387e9fe
MD5 8dca2e04d0bd1d959466c222200315b8
BLAKE2b-256 960a30728f425de1adc0cc65dfe95b5ae8f7c8261ab63a0d44c2db32bbacaa39

See more details on using hashes here.

File details

Details for the file rstar_python-0.0.1-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rstar_python-0.0.1-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0223a0852d46f5c2880ec3ef2aef519bc088fc666b76d0ce322482bcfdc18c3c
MD5 e057327940c3b9a2d5e10536c57c048e
BLAKE2b-256 6ed34935ec1fad7b7fa9499a6655620c7c3773e335f5cc639c4e08b84b49142c

See more details on using hashes here.

File details

Details for the file rstar_python-0.0.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for rstar_python-0.0.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 29f7afe7629f03ae7760e0af0532b9be6f95d97b0fc0f8bb47f3105a1962e808
MD5 85b2c801a31d74db323fe5635c2e7d87
BLAKE2b-256 2d6f49191a1efce2ccc98e23c50b93be3ff3e986a72834c84850171b6a0a11b6

See more details on using hashes here.

File details

Details for the file rstar_python-0.0.1-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rstar_python-0.0.1-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 af798ecb98c871f21763fb9f4a826c58801b2d81d26eaba598f806acf2bb4e9c
MD5 f0849e42ec66ae2f3229ab2b41e20f87
BLAKE2b-256 87f1d05d115631cc8a86db66eacc148055563fe5269639f926999ee538d6d2f2

See more details on using hashes here.

File details

Details for the file rstar_python-0.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rstar_python-0.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d4770bc8095a6ba68755a9497293341827d12ceba80c81c9f9c85043f1dd42e3
MD5 65bc8b513694e1a243fa512432c85337
BLAKE2b-256 d56497e5b26cbc7a59ff9aac16b9a3719b5445575e6c84c0bdf14529b588cc71

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