Spatio is a lightweight, high-performance embedded spatial database written in Rust. It’s designed for real-time location data, with low memory usage, optional persistence, and native Python bindings.
Unlike traditional GIS or SQL-based systems, Spatio offers a direct API for spatial operations — no SQL parser, no external dependencies, and no setup required.
Features
Embedded and Lightweight
- Fully Self-Contained — No servers, daemons, or dependencies
- Simple API — Just open, insert, and query
- Low Memory Usage — Ideal for IoT, edge, and embedded devices
- Thread-Safe by Design — Safe concurrent read/write via
Arc<RwLock>
Performance-Focused
- High Throughput — Millions of operations per second in-memory
- Low Latency — Microsecond-level point and radius queries
- Configurable Persistence — Append-Only File (AOF) with sync policies
- Graceful Startup and Shutdown — Automatic AOF replay and sync
Spatial Intelligence
- Spatial Indexing — R-Tree + geohash hybrid indexing
- Spatial Queries — Nearby search, bounding box, distance, containment
- Trajectory Support — Store and query movement over time
- GeoJSON I/O — Native import/export of geometries
Data Management
- Namespaces — Isolate data logically within the same instance
- TTL Support — Auto-expiring data for temporal use cases
- Atomic Batches — Transaction-like grouped operations
- Custom Configs — JSON/TOML serializable configuration
Language Support
- Rust — Native API for maximum performance
- Python — Native bindings via PyO3 (
pip install spatio)
Installation
Python
📦 PyPI: https://pypi.org/project/spatio
Rust
Add this to your Cargo.toml:
[]
= "0.1"
📦 Crates.io: https://crates.io/crates/spatio
Quick Start
Python
# Open (or create) a persistent database backed by an append-only file
=
=
=
# Insert a geographic point; keys under the same prefix are indexed together
# Run a nearby search (returns Point, value, distance tuples)
=
# Store and retrieve plain key-value data alongside spatial items
# b'Jane Doe'
Rust
use *;
use Duration;
Examples
Run the included examples to see Spatio in action:
Getting Started
Spatial Queries
Trajectory Tracking
Architecture Demo (New!)
Comprehensive Demo
Use Cases
Local Spatial Analytics
- Proximity Search: Efficiently find nearby features or points of interest
- Containment Queries: Check if points or geometries lie within defined areas
- Spatial Relationships: Analyse intersections, distances, and overlaps between geometries
Edge & Embedded Systems
- On-Device Processing: Run spatial queries directly on IoT, drones, or edge devices
- Offline Operation: Perform location analytics without cloud or network access
- Energy Efficiency: Optimised for low memory and CPU usage in constrained environments
Developer & Research Tools
- Python Integration: Use Spatio natively in data analysis or geospatial notebooks
- Simulation Support: Model trajectories and spatial behaviours locally
- Lightweight Backend: Ideal for prototypes, research projects, or local GIS tools
Offline & Mobile Applications
- Local Data Storage: Keep spatial data close to the application
- Fast Query Engine: Sub-millisecond lookups for geometry and location queries
- Self-Contained: No external dependencies or server required
API Overview
Core Operations
// Basic key-value operations
db.insert?;
let value = db.get?;
db.delete?;
Spatial Operations
let point = new;
// Insert point with automatic spatial indexing
db.insert_point?;
// Find nearby points
let nearby = db.find_nearby?;
// Check if points exist in region
let exists = db.contains_point?;
// Count points within distance
let count = db.count_within_distance?;
// Query bounding box
let in_bounds = db.find_within_bounds?;
let intersects = db.intersects_bounds?;
Trajectory Tracking
// Store movement over time
let trajectory = vec!;
db.insert_trajectory?;
// Query trajectory for time range
let path = db.query_trajectory?;
Atomic Operations
db.atomic?;
Time-to-Live (TTL)
// Data expires in 1 hour
let opts = with_ttl;
db.insert?;
Performance Highlights
Recent release-build benchmarks on Apple Silicon show:
- Key-value operations: ~1.6M ops/sec (≈600ns per write)
- Spatial insertions: ~1.9M points/sec (≈530ns per point)
- Spatial queries: ~225K queries/sec (≈4.4µs per query)
Throughput depends on workload and hardware, but the engine is tuned for low-latency, in-memory operation with optional append-only persistence.
Architecture Overview
Spatio is organized in layered modules:
- Storage – Pluggable backends (in-memory by default, AOF for durability) with a common trait surface.
- Indexing – Geohash-based point index with configurable precision and smart fallback during searches.
- Query – Radius, bounding-box, and trajectory primitives that reuse the shared index and TTL cleanup workers.
- API – Ergonomic Rust API plus PyO3 bindings that expose the same core capabilities.
See the docs site for deeper architectural notes.
Project Status
- Current version: 0.1.1
- Alpha quality: APIs may still change while we lock in the storage layout.
- Follow releases for migration notes and roadmap updates.
Contributing
Contributions are welcome! Please read our Contributing Guidelines before submitting pull requests.
Development Setup
Links & Resources
Package Repositories
- PyPI: https://pypi.org/project/spatio
- Crates.io: https://crates.io/crates/spatio
Documentation & Source
- GitHub Repository: https://github.com/pkvartsianyi/spatio
- Rust Documentation: https://docs.rs/spatio
- Python Documentation: https://github.com/pkvartsianyi/spatio/tree/main/py-spatio
Community
- Issues & Bug Reports: https://github.com/pkvartsianyi/spatio/issues
- Releases & Changelog: https://github.com/pkvartsianyi/spatio/releases
License
MIT License (LICENSE)
Acknowledgments
- Built with the Rust ecosystem's excellent geospatial libraries
- Inspired by modern embedded databases and spatial indexing research
- Thanks to the Rust community for feedback and contributions