rtree
R-Tree spatial index for Python GIS
What it is and what it does
Rtree is a Python wrapper around libspatialindex that brings spatial indexing capabilities to Python applications. It allows you to build and query multi-dimensional spatial structures—such as geographic boundaries, bounding boxes, or point clouds—using R-Tree data structures. The package supports nearest-neighbor search, intersection queries, bulk loading, disk serialization, and custom storage backends, making it useful for GIS systems, spatial databases, and scientific computing.
The package has no runtime Python dependencies and supports Python 3.9 through 3.13. It is classified as production-stable with nearly 10 million monthly downloads and active maintenance, making it a mature choice for spatial indexing in Python.
Use it for:
- Build a geographic information system (GIS) that queries which map features intersect a user's viewport.
- Implement nearest-neighbor search in a spatial database to find the closest points of interest to a given location.
- Index and query multi-dimensional scientific data (e.g., particle positions in a simulation) for fast spatial lookups.
- Store and retrieve spatial metadata (e.g., bounding boxes) alongside Python objects using clustered indexes.
- Bulk-load large spatial datasets and serialize the index to disk for repeated queries without rebuilding.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Rtree wraps libspatialindex to provide spatial indexing for Python, enabling nearest-neighbor search, intersection queries, and multi-dimensional spatial data structures.
Yes. Rtree is a mature, actively maintained package with no known vulnerabilities, permissive MIT licensing, and broad platform support. Install friction is medium due to compiled dependencies. Choose it if you need spatial indexing for GIS, scientific computing, or spatial databases.
Install
rtree on PyPI
pip
pip install rtreeuv
uv add rtreepoetry
poetry add rtreeInstalling rtree
Before you install
Medium install friction due to compiled C dependencies. Pre-built distributions are available for most major platforms. Package is actively maintained with a recent commit on 2026-08-10 and has been stable since its early releases.
License in practice
MIT license is permissive; you can use, modify, and distribute this package with minimal restrictions, making it suitable for both open-source and commercial projects.
Quickstart
pip install rtree
from rtree import index
# Create a spatial index
idx = index.Index()
idx.insert(1, (0.0, 0.0, 1.0, 1.0))
# Query for intersecting geometries
list(idx.intersection((0.5, 0.5, 1.5, 1.5)))
Requires libspatialindex system library; on some systems you may need to install it separately before pip install succeeds.
Verify before relying
- Whether libspatialindex in distributed packages is current and patched for known vulnerabilities.
- Performance characteristics (index build time, query latency) for typical dataset sizes in GIS or scientific applications.
- Whether bundled libspatialindex is included in all distribution channels or requires separate installation on some platforms.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 366 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 9,823,017/month — #1,497 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: rtree-1.4.1-py3-none-macosx_10_9_x86_64.whl; rtree-1.4.1-py3-none-macosx_11_0_arm64.whl; rtree-1.4.1-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; rtree-1.4.1-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; rtree-1.4.1-py3-none-musllinux_1_2_aarch64.whl; rtree-1.4.1-py3-none-musllinux_1_2_x86_64.whl; rtree-1.4.1-py3-none-win_amd64.whl; rtree-1.4.1-py3-none-win_arm64.whl
Keywords: gis, spatial, index, r-tree
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
kdtreeConstructs, modifies, and searches…
permissive · top 15,000 on PyPI
pynndescentPyNNDescent builds approximate nearest neighbor…
permissive · top 5,000 on PyPI
spatial_imagespatial-image provides an N-dimensional spatial…
permissive · top 15,000 on PyPI
spaghettiSpaghetti analyzes network-based spatial data…
permissive · top 15,000 on PyPI
py-geohex3Converts between geographic coordinates…
permissive · top 15,000 on PyPI
h3h3 provides Python bindings to Uber's H3…
permissive · top 5,000 on PyPI
s2spheres2sphere provides Python bindings to work with…
permissive · top 15,000 on PyPI
usearchUSearch provides approximate nearest-neighbor…
permissive · top 15,000 on PyPI
accessCalculates spatial accessibility metrics to…
permissive · top 15,000 on PyPI
python-geohashpython-geohash encodes and decodes geographic…
unclear · top 15,000 on PyPI