Geospatial query engine with dynamic index selection
Project description
PyCanopy
A geospatial query engine with automatic index selection. Written in Rust, callable from Python.
PyCanopy accepts point datasets and answers spatial queries (k-nearest neighbours, bounding-box range, point-in-polygon) by automatically choosing the fastest index — R-tree, KD-tree, uniform grid, or brute force — based on dataset size, geometry kind, and spatial distribution.
Installation
pip install pycanopy
Note: Pre-built wheels are provided for Linux, macOS, and Windows. No Rust toolchain required.
Quick start
import numpy as np
from pycanopy import Engine
coords = np.random.uniform(0, 100, size=(50_000, 2))
engine = Engine(coords)
indices = engine.knn(x=42.0, y=37.0, k=10)
indices = engine.range_query(min_x=10.0, min_y=10.0, max_x=50.0, max_y=50.0)
indices = engine.contains(x=25.0, y=25.0)
Accepted input formats
| Format | Example |
|---|---|
numpy (N, 2) array |
np.array([[x, y], ...]) |
| GeoArrow PyArrow array | pa.StructArray or FixedSizeList<2> |
geopandas GeoSeries |
gdf.geometry |
| list of shapely Points | [Point(x, y), ...] |
list of (x, y) tuples |
[(x, y), ...] |
| Separate coordinate lists | Engine.from_coords(xs, ys) |
How index selection works
| Condition | Index chosen |
|---|---|
| N < 500 or selectivity > 50% | Brute force |
| Points + kNN | KD-tree |
| Points + uniform + range | Uniform grid |
| Points + clustered + range | KD-tree |
| Polygons or mixed geometries | R-tree |
Development setup
Requires Python >= 3.9 and a Rust toolchain (rustup.rs).
git clone https://github.com/pranavwalimbe/pycanopy
cd pycanopy
uv sync --group dev
uv run maturin develop
uv run pytest
cargo test
License
MIT
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycanopy-0.1.0.tar.gz.
File metadata
- Download URL: pycanopy-0.1.0.tar.gz
- Upload date:
- Size: 30.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e81bd71554d1a6d70202220da3be0230663a2ccbd8c4f3630cf1e90155d27c63
|
|
| MD5 |
bfd0b78fc769b8e686ac2e97994b84d8
|
|
| BLAKE2b-256 |
b792bad55ed0a7b06770830304fc82da411f10f3346a5448660d19a7b576061f
|
Provenance
The following attestation bundles were made for pycanopy-0.1.0.tar.gz:
Publisher:
release.yml on pranav-walimbe/PyCanopy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycanopy-0.1.0.tar.gz -
Subject digest:
e81bd71554d1a6d70202220da3be0230663a2ccbd8c4f3630cf1e90155d27c63 - Sigstore transparency entry: 1697133836
- Sigstore integration time:
-
Permalink:
pranav-walimbe/PyCanopy@779c69789e3e6b03fa7c2f486f6ac34c9d533955 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/pranav-walimbe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@779c69789e3e6b03fa7c2f486f6ac34c9d533955 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pycanopy-0.1.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: pycanopy-0.1.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 187.8 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ddc11384d53c1d4997abd7bec6ac5b7b0937b813ec2382c098b3b38b7c61ad2
|
|
| MD5 |
28b970065535aaebf15ebeb88a5ecd7c
|
|
| BLAKE2b-256 |
ef003e457ba8f2ca0efb2ebdb6e62c0758426b34ebb092a788319a68241853c0
|
Provenance
The following attestation bundles were made for pycanopy-0.1.0-cp39-abi3-win_amd64.whl:
Publisher:
release.yml on pranav-walimbe/PyCanopy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycanopy-0.1.0-cp39-abi3-win_amd64.whl -
Subject digest:
8ddc11384d53c1d4997abd7bec6ac5b7b0937b813ec2382c098b3b38b7c61ad2 - Sigstore transparency entry: 1697134274
- Sigstore integration time:
-
Permalink:
pranav-walimbe/PyCanopy@779c69789e3e6b03fa7c2f486f6ac34c9d533955 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/pranav-walimbe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@779c69789e3e6b03fa7c2f486f6ac34c9d533955 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pycanopy-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pycanopy-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 297.7 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
401b733cce5f786f7360fefcd84b685e62fee3655b02c78c12e4ec6ec46252b6
|
|
| MD5 |
d145d0518290041dc6d5729fab3e04a9
|
|
| BLAKE2b-256 |
db320a617c3d89c5cb481b7facbf92e94a8e738b0ad356f187ac0c3666c1afe1
|
Provenance
The following attestation bundles were made for pycanopy-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on pranav-walimbe/PyCanopy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycanopy-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
401b733cce5f786f7360fefcd84b685e62fee3655b02c78c12e4ec6ec46252b6 - Sigstore transparency entry: 1697133915
- Sigstore integration time:
-
Permalink:
pranav-walimbe/PyCanopy@779c69789e3e6b03fa7c2f486f6ac34c9d533955 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/pranav-walimbe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@779c69789e3e6b03fa7c2f486f6ac34c9d533955 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pycanopy-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pycanopy-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 289.7 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b32aa7f7f20aa04bfd8c1e3743ed4df7e8fc3c54736d8db3d45b3deaf03f0a1
|
|
| MD5 |
47b476f77b1ada352aa002bef1be22c2
|
|
| BLAKE2b-256 |
490d4d858a53664dd32bfaef34b9df5a57da5917cfa3c659e67263a139f3f87b
|
Provenance
The following attestation bundles were made for pycanopy-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on pranav-walimbe/PyCanopy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycanopy-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
1b32aa7f7f20aa04bfd8c1e3743ed4df7e8fc3c54736d8db3d45b3deaf03f0a1 - Sigstore transparency entry: 1697134351
- Sigstore integration time:
-
Permalink:
pranav-walimbe/PyCanopy@779c69789e3e6b03fa7c2f486f6ac34c9d533955 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/pranav-walimbe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@779c69789e3e6b03fa7c2f486f6ac34c9d533955 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pycanopy-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: pycanopy-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 268.7 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e21f012d8494cc88887d43bbc509e42d37aedb90282876e975de1c3bee5e3a87
|
|
| MD5 |
65a7c2521f84a6a144136710d5476de2
|
|
| BLAKE2b-256 |
51975503f6acc73d77f2dc25a239239562415aeeff8a2aff1f8318e70d8b1b76
|
Provenance
The following attestation bundles were made for pycanopy-0.1.0-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on pranav-walimbe/PyCanopy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycanopy-0.1.0-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
e21f012d8494cc88887d43bbc509e42d37aedb90282876e975de1c3bee5e3a87 - Sigstore transparency entry: 1697133996
- Sigstore integration time:
-
Permalink:
pranav-walimbe/PyCanopy@779c69789e3e6b03fa7c2f486f6ac34c9d533955 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/pranav-walimbe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@779c69789e3e6b03fa7c2f486f6ac34c9d533955 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pycanopy-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pycanopy-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 280.7 kB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8febbfa67e072c27e774dfbd49c8905fb29356a90a6cd832bb7ffe1aa4ab0449
|
|
| MD5 |
cb4c25f1f4bfdf420cbdc8f591ce6015
|
|
| BLAKE2b-256 |
504ef4a50fcd83f6c31c851baf93473dab28c789a5d00727d7b0c599f7205cc6
|
Provenance
The following attestation bundles were made for pycanopy-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on pranav-walimbe/PyCanopy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycanopy-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl -
Subject digest:
8febbfa67e072c27e774dfbd49c8905fb29356a90a6cd832bb7ffe1aa4ab0449 - Sigstore transparency entry: 1697134096
- Sigstore integration time:
-
Permalink:
pranav-walimbe/PyCanopy@779c69789e3e6b03fa7c2f486f6ac34c9d533955 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/pranav-walimbe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@779c69789e3e6b03fa7c2f486f6ac34c9d533955 -
Trigger Event:
push
-
Statement type: