kdtree-rs
Library Featured
K-dimensional tree in Rust for fast geospatial indexing and nearest neighbors lookup
- Downloads
- 388,481
- Dependents
- 29
- Stars
- 286
- Forks
- 64
- Contributors
- 18
- Commits
- 124
- Latest release
- 0.8.1 ·
About
K-dimensional tree in Rust for fast geospatial indexing and nearest neighbors lookup
- Crate
- Documentation
- Usage
- Benchmark
- License
Usage
Add kdtree to Cargo.toml
[dependencies]
kdtree = "0.8.1"
Add points to kdtree and query nearest n points with distance function
Read the full README
use kdtree::KdTree;
use kdtree::ErrorKind;
use kdtree::distance::squared_euclidean;
let a: ([f64; 2], usize) = ([0f64, 0f64], 0);
let b: ([f64; 2], usize) = ([1f64, 1f64], 1);
let c: ([f64; 2], usize) = ([2f64, 2f64], 2);
let d: ([f64; 2], usize) = ([3f64, 3f64], 3);
let dimensions = 2;
let mut kdtree = KdTree::new(dimensions);
kdtree.add(&a.0, a.1).unwrap();
kdtree.add(&b.0, b.1).unwrap();
kdtree.add(&c.0, c.1).unwrap();
kdtree.add(&d.0, d.1).unwrap();
assert_eq!(kdtree.size(), 4);
assert_eq!(
kdtree.nearest(&a.0, 0, &squared_euclidean).unwrap(),
vec![]
);
assert_eq!(
kdtree.nearest(&a.0, 1, &squared_euclidean).unwrap(),
vec![(0f64, &0)]
);
assert_eq!(
kdtree.nearest(&a.0, 2, &squared_euclidean).unwrap(),
vec![(0f64, &0), (2f64, &1)]
);
assert_eq!(
kdtree.nearest(&a.0, 3, &squared_euclidean).unwrap(),
vec![(0f64, &0), (2f64, &1), (8f64, &2)]
);
assert_eq!(
kdtree.nearest(&a.0, 4, &squared_euclidean).unwrap(),
vec![(0f64, &0), (2f64, &1), (8f64, &2), (18f64, &3)]
);
assert_eq!(
kdtree.nearest(&a.0, 5, &squared_euclidean).unwrap(),
vec![(0f64, &0), (2f64, &1), (8f64, &2), (18f64, &3)]
);
assert_eq!(
kdtree.nearest(&b.0, 4, &squared_euclidean).unwrap(),
vec![(0f64, &1), (2f64, &0), (2f64, &2), (8f64, &3)]
);
Benchmark
cargo bench with 2.3 GHz Intel i5-7360U:
cargo bench
Running target/release/deps/bench-9e622e6a4ed9b92a
running 2 tests
test bench_add_to_kdtree_with_1k_3d_points ... bench: 106 ns/iter (+/- 25)
test bench_nearest_from_kdtree_with_1k_3d_points ... bench: 1,237 ns/iter (+/- 266)
test result: ok. 0 passed; 0 failed; 0 ignored; 2 measured; 0 filtered out
Thanks Eh2406 for various fixes and perf improvements.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Compatibility
- Runs on
- GPU support unknown
What shows it
- no dependency or feature matches a backend row
- Native code
- None found
- No native code found
- Python bindings
- No Python binding crate found
- License
- Apache-2.0 OR MIT
Compare with similar projects
Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.
| Project | Downloads | Dependents | Stars | Latest release | Runs on (GPU) | Native code | License |
|---|---|---|---|---|---|---|---|
|
K-dimensional tree in Rust for fast geospatial indexing and nearest neighbors lookup |
388,481 downloads over 30 days | 29 | 286 | 0.8.1 | GPU support unknown | No native code found | Apache-2.0 OR MIT |
|
kiddo Featured
A high-performance, flexible, ergonomic k-d tree library. Ideal for geo- and astro- nearest-neighbour and k-nearest-neighbor queries |
481,504 downloads over 30 days | 56 | 179 | 6.3.0 | GPU support unknown | Build uses a native toolchain: cc (feature cpp_competitors) | Apache-2.0 OR MIT |
|
arroy Listed
Annoy-inspired Approximate Nearest Neighbors in Rust, based on LMDB and optimized for memory usage |
22,053 downloads over 30 days | 6 | 314 | 0.9.0 | GPU support unknown | Binds native code: lmdb-master-sys | MIT |
|
Fast approximate nearest neighbors |
15,542 downloads over 30 days | 13 | 268 | 0.11.0 | GPU support unknown | No native code found | MIT |
|
splintr Listed
Tokenizer for Rust and Python: pure Rust by default, with 18 bundled vocabularies and four backends covering BPE, SentencePiece and WordPiece. Its output matches Hugging Face tokenizers id for id on 14 model families, including GPT-2, Qwen, Whisper, T5 and BERT. Python bindings |
8,204 downloads over 30 days | 7 | 63 | 0.22.2 | GPU support unknown | Binds native code: pcre2-sys (feature pcre2) | MIT |
|
Vantage Point Tree search algorithm for fast nearest neighbour search in multi-dimensional metric spaces. |
919 downloads over 30 days | 2 | 32 | 2.1.0 | GPU support unknown | No native code found | BSD-2-Clause |
|
instant-distance Archived
Fast minimal implementation of HNSW maps for approximate nearest neighbors searches |
96,520 downloads over 30 days | 36 | 343 | 0.6.1 | GPU support unknown | No native code found | Apache-2.0 OR MIT |
Why FeaturedIt passes every Featured gate.
What it meets
- It has 18 active dependents and 6 new dependents in 365 days. Featured needs 11 active dependents or 9 new dependents in 365 days.
- Active dependents are at 97% of their peak. Featured needs at least 50%.
- Docs are present. The release commit or a manifest ties the crate to the repository.
- No vulnerability advisory stays unpatched past the grace window. At least one version is neither a prerelease nor 0.0.x.
- The last activity is on 23 Jul 2026, 109 days ago. The rules expect an update within 1200 days. Dormancy rule
Exact rules: Featured library. The check on applied thresholds version 9.
Every rule outcome, as the check records it
expected-interval: version 0.8.1 base 300, doubled for 388481 downloads per month, doubled for 18 active users: E = 1200 daysdormancy: last activity 2026-07-23, 109 days ago, E = 1200: activefeatured: featured: active_users 18, new_adopters 6, former_glory 0.97
Measurements and sources
Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.
Sources6 sources
- Description: the crates.io description
- crates.io database dump, fetched
- RustSec advisory database, fetched
- GitHub repository, fetched
- crates.io package, fetched
- GitHub contributors, fetched
Adoption18 active dependents, 6 new dependents in 365 days1 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Active dependents | 18 | crates.io database dump | Yes | |
| New dependents (365 days) | 6 | crates.io database dump | Yes | |
| Peak active dependents | 20 | crates.io database dump | Yes | |
| Active dependents as a share of the peak | 0.975 | crates.io database dump | Yes | |
| Binary downloads per release | Not measured | Yes |
MaintenanceLatest human commit: 3 months ago3 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Latest human commit | 2026-07-23 | GitHub repository | Yes | |
| Latest release | 2026-07-23 | crates.io database dump | Yes | |
| First release | 2015-08-08 | crates.io database dump | Yes | |
| Latest version | 0.8.1 | crates.io database dump | Yes | |
| Days the oldest outside issue waits for a reply | 649 | GitHub repository | Yes | |
| Maintainer replies over 365 days | 1 | GitHub repository | Yes | |
| Repository archived | false | GitHub repository | Yes | |
| Repository gone | false | GitHub repository | Yes | |
| Release commit or manifest in the repo | true | crates.io package | Yes | |
| Published docs | true | crates.io database dump | Yes | |
| Latest release fails cargo check | Not measured | Yes | ||
| Build check date | Not measured | Yes | ||
| Build check toolchain | Not measured | Yes |
SecurityUnpatched vulnerabilities: none
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Unpatched vulnerabilities past the grace window | none | RustSec advisory database | Yes | |
| RustSec unmaintained advisory | none | RustSec advisory database | Yes | |
| Deprecation notice | none | crates.io database dump | Yes | |
| Deprecated requirement | none | crates.io database dump | Yes |
Distribution15 releases, 388,481 downloads over 30 days5 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Releases | 15 | crates.io database dump | Yes | |
| Downloads over 30 days | 388481 | crates.io database dump | Yes | |
| Binary downloads over the last 3 releases | Not measured | Yes | ||
| Homebrew installs on request over 365 days | Not measured | Yes | ||
| Repology repository families | Not measured | Yes | ||
| Docker pull growth over 90 days | Not measured | Yes | ||
| Docker pulls at the growth baseline | Not measured | Yes | ||
| Every version a prerelease | false | crates.io database dump | Yes | |
| Every version 0.0.x | false | crates.io database dump | Yes | |
| Every version yanked | false | crates.io database dump | Yes | |
| Crate deleted from crates.io | false | crates.io database dump | Yes |
Repository286 stars, 64 forks, 18 contributors, 124 commits. Stars alone never qualify a project.
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| GitHub stars | 286 | GitHub repository | Yes — one part of the repository route | |
| GitHub forks | 64 | GitHub repository | Yes — one part of the repository route | |
| Contributors with a GitHub account | 18 | GitHub contributors | Yes — one part of the repository route | |
| Commits on the default branch | 124 | GitHub repository | No | |
| Repository's main crate left out of the entry | none | crates.io database dump | Yes |
Facts that never count
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| License | Apache-2.0 OR MIT | crates.io database dump | No | |
| Runs on, from listed crates and their direct dependencies | GPU support unknown | crates.io database dump | No | |
| What shows each backend | no dependency or feature matches a backend row | crates.io database dump | No | |
| Native code, from listed crates and their dependencies | No native code found | crates.io database dump | No | |
| Python bindings, from direct dependencies of listed crates | No Python binding crate found | crates.io database dump | No | |
| Crates that depend on a listed crate directly | 29 | crates.io database dump | No |
Corrections and review history
No correction applies to this entry.
Judgments
A judgment enters only through an approved issue and a merged pull request.
No judgment applies to this entry.