Blazingly fast spatio-temporal database library
Project description
Spatio for Python
High-performance spatial database for Python, powered by Rust.
What is it?
Spatio is an embedded database optimized for tracking moving objects. It uses a specialized Hot/Cold State architecture to provide real-time spatial queries and historical trajectory tracking with minimal overhead.
Quick Start
import spatio
# Open an in-memory database
db = spatio.Spatio.memory()
# Track a moving object
pos = spatio.Point(-74.006, 40.712, altitude=10.0)
db.upsert("drones", "drone_1", pos, {"status": "active"})
# Find objects within 500 meters
nearby = db.query_radius("drones", pos, radius=500, limit=10)
for object_id, point, metadata, distance in nearby:
print(f"Found {object_id} at {distance:.1f}m")
core API
Spatio (Local Database)
import spatio
# Creation
db = spatio.Spatio.memory()
db = spatio.Spatio.open("data.db")
# Tracking
db.upsert(namespace, object_id, point, metadata=None)
db.get(namespace, object_id) # Returns CurrentLocation or None
db.delete(namespace, object_id)
# Proximity Queries
# Returns list of (object_id, point, metadata, distance)
db.query_radius(namespace, center_point, radius, limit=100)
db.query_near(namespace, object_id, radius, limit=100)
# K-Nearest Neighbors
db.knn(namespace, center_point, k)
db.knn_near_object(namespace, object_id, k)
# Volume Queries
db.query_bbox(namespace, min_x, min_y, max_x, max_y, limit=100)
db.query_within_cylinder(namespace, center_point, min_z, max_z, radius, limit=100)
db.query_within_bbox_3d(namespace, min_x, min_y, min_z, max_x, max_y, max_z, limit=100)
# Relative Queries
db.query_bbox_near_object(namespace, object_id, width, height, limit=100)
db.query_cylinder_near_object(namespace, object_id, min_z, max_z, radius, limit=100)
# Trajectories
db.insert_trajectory(namespace, object_id, list_of_temporal_points)
db.query_trajectory(namespace, object_id, start_ts, end_ts, limit=100)
Data Types
Point
spatio.Point(lon, lat, altitude=0.0)
point.lon,point.lat,point.altpoint.distance_to(other_point)-> distance in meters (Haversine)
TemporalPoint
spatio.TemporalPoint(point, timestamp)
- Used for bulk trajectory ingestion.
Performance Tips
- Namespaces: Use namespaces to logically separate different types of objects (e.g., "delivery_trucks", "warehouses").
- Object Queries: Use
query_nearorknn_near_objectwhenever possible, as they avoid re-passing coordinates and leverage the internal Hot State index directly.
License
MIT - see LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
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 spatio-0.2.4-cp313-cp313-manylinux_2_35_x86_64.whl.
File metadata
- Download URL: spatio-0.2.4-cp313-cp313-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 519.5 kB
- Tags: CPython 3.13, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ff602a684bf554813121938415dcf352af2e530141e2706ac53ddc724e64599
|
|
| MD5 |
d0a910075ace9a5d0eb8fb5270827aeb
|
|
| BLAKE2b-256 |
783158312e946024507ceab725a9a7baed05c285eb40763cc7db7874d231e5fb
|
File details
Details for the file spatio-0.2.4-cp312-cp312-manylinux_2_35_x86_64.whl.
File metadata
- Download URL: spatio-0.2.4-cp312-cp312-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 519.3 kB
- Tags: CPython 3.12, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bcb3a60b5cef274c04f9ede30c61f0172e1e0c94ce1bb8e31f7bdfeac6a1b14
|
|
| MD5 |
17b86b3a062507d82686e76117f39285
|
|
| BLAKE2b-256 |
c96ed4db115422bf602d5db8a09e961192b835b315fd2c2ccc3586f87528aec0
|
File details
Details for the file spatio-0.2.4-cp311-cp311-manylinux_2_35_x86_64.whl.
File metadata
- Download URL: spatio-0.2.4-cp311-cp311-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 519.5 kB
- Tags: CPython 3.11, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1f5d7691b2502f805b9b0b3f38eaf36f511e1724e0954960069dbbcb5a08806
|
|
| MD5 |
fade9631e331ad60823b9fc1dc177fbc
|
|
| BLAKE2b-256 |
cec7a87bd086077cdba2030c771ed35edbdc174ac7122b0ad2a8f034cf6058c4
|
File details
Details for the file spatio-0.2.4-cp310-cp310-manylinux_2_35_x86_64.whl.
File metadata
- Download URL: spatio-0.2.4-cp310-cp310-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 522.2 kB
- Tags: CPython 3.10, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd48dd7d16de441ea903a4a1477d85dc37839039ee3f22ff4ad1ec332063700f
|
|
| MD5 |
45575914f712510ca6bca6a6eff72b7f
|
|
| BLAKE2b-256 |
9acb7887b44ffc330a48db27836a9e1daacfae99d1e6149904b7a05e83d02c32
|
File details
Details for the file spatio-0.2.4-cp39-cp39-manylinux_2_35_x86_64.whl.
File metadata
- Download URL: spatio-0.2.4-cp39-cp39-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 526.2 kB
- Tags: CPython 3.9, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a00f7cf074c884f97ee85ca9dfe44cefb6a7b87d4faff650b0d5698b7b0f951
|
|
| MD5 |
ee7bea9d10f7074cddffe9e033b51175
|
|
| BLAKE2b-256 |
49e455c8f986aa83607020ec6ce13025f867cc10a596b1ac0e7deb29e28ba2e8
|