// the find
Toblerity/rtree
Rtree: spatial index for Python GIS
Rtree is a Python wrapper around libspatialindex that gives you R-tree spatial indexes — bounding-box intersection queries, nearest-neighbor search, and multi-dimensional indexing. It's the go-to choice when you need fast spatial lookups in a Python GIS stack without pulling in PostGIS or a full geodatabase.
Pre-built wheels with bundled libspatialindex mean `pip install rtree` just works on Windows, Mac, and Linux without fighting native build dependencies. The API covers the full libspatialindex feature set including bulk loading, disk serialization, and clustered indexes that store pickled objects alongside index entries — useful for tight query loops where you want to avoid a second data lookup. Active CI on main branch as of June 2026 with dependabot on workflows suggests someone is still minding the project. Multi-dimensional support (not just 2D) is genuinely useful for time-space indexing without needing a separate library.
682 stars for a 10+ year old library is a tell — Shapely's STRtree, scipy's cKDTree, and PyGEOS have eaten most of its lunch for in-memory use cases, and anyone on PostGIS doesn't need it at all. The ctypes bridge to libspatialindex is a liability: it adds a native dependency under the hood even when wheels hide it, and debugging crashes is painful. No async support anywhere, which matters if you're doing spatial queries inside an async web stack. The clustered index feature (storing pickles directly in the index) sounds useful but is essentially undocumented in the README — you have to dig through the full docs or source to understand what you're actually getting.