PyCanopy introduces a high-performance spatial query layer designed specifically for Polars, leveraging a Rust core for speed and efficiency. It simplifies spatial queries while maintaining Polars-like syntax, offering the advantages of relational databases, such as query planning and indexing, in a seamless dataframe interface.
PyCanopy is an innovative spatial query layer designed specifically for the Polars DataFrame engine. By leveraging a Rust core and a Python API, it optimizes spatial queries while maintaining the familiar syntax of Polars, making it accessible to data professionals.
PyCanopy has proven its competitive edge in benchmarks against renowned libraries. In the Apache SpatialBench, it achieved outstanding results, being the fastest on multiple queries:
Here is a brief overview of the performance on SF1 and SF10 datasets:
| Query | PyCanopy | SedonaDB | DuckDB | GeoPandas |
|---|---|---|---|---|
| q1 | 1.41 | 0.66 | 0.96 | 12.78 |
| q2 | 3.94 | 8.07 | 9.95 | 20.74 |
| ... | ... | ... | ... | ... |
| q12 | 14.00 | 14.55 | ERROR | TIMEOUT |
Below is an example of how to utilize PyCanopy for spatial queries:
import polars as pl
from pycanopy import SpatialFrame
# Create a SpatialFrame from a dataset
sf = SpatialFrame(pl.read_parquet("cities.parquet"), x_col="lon", y_col="lat")
# Perform a lazy spatial range query
result = sf.lazy()
.filter(pl.col("population") > 100_000)
.range_query(-10.0, 35.0, 40.0, 70.0)
.collect()
PyCanopy supports a wide array of complex spatial operations:
The engine uses advanced query planning techniques, including:
For users needing high-performance spatial operations within a Polars DataFrame, PyCanopy provides:
For further details and documentation, please refer to the official documentation.
No comments yet.
Sign in to be the first to comment.