Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jblindsay/kdtree
A pure Nim k-d tree implementation for efficient spatial querying of point data
https://github.com/jblindsay/kdtree
gis spatial-analysis spatial-data
Last synced: 3 months ago
JSON representation
A pure Nim k-d tree implementation for efficient spatial querying of point data
- Host: GitHub
- URL: https://github.com/jblindsay/kdtree
- Owner: jblindsay
- License: mit
- Created: 2020-04-11T00:59:00.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-11-10T20:57:37.000Z (almost 4 years ago)
- Last Synced: 2024-06-11T18:34:33.127Z (5 months ago)
- Topics: gis, spatial-analysis, spatial-data
- Language: Nim
- Size: 301 KB
- Stars: 42
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nim - kdtree - A pure Nim k-d tree implementation for efficient spatial querying of point data. (Data / Data Structures)
README
# kdtree
**Contents**
1. [Description](#1-description)
2. [Documentation](#2-documentation)
3. [Usage](#2-usage)## 1 Description
**kdtree** is a pure Nim [k-d tree](https://en.wikipedia.org/wiki/K-d_tree) implementation. k-d trees are data structures for performing efficient spatial query operations on point data sets. This implementation is very flexible, allowing for nearest-neighbour (single and multiple), within-radius (circular search areas), and range (rectangular search areas) spatial queries.
## 2 Documentation
Documentation for `kdtree` can be found [here](https://jblindsay.github.io/kdtree/kdtree.html).
## 3 Usage
```nim
import random, strformat
import kdtree
# Generate 100,000 random points
let numPoints = 100_000
var
points = newSeqOfCap[array[2, float]](numPoints)
values = newSeqOfCap[int](numPoints)
x: float
y: float
r = initRand(34)
for a in 0.. 1:
tree.rebalance()############################
# Spatial query operations #
############################# Perform nearestNeighour searches
let numSearches = 10_000
for a in 0..