Skip to main content

R-Tree spatial index for Python GIS

Project description

Whether for in-memory feature stores, Plone content, or whatever – we need an index to speed up the search for objects that intersect with a spatial bounding box.

See also CHANGES.txt.

Index Protocol

In a nutshell:

>>> from rtree import Rtree
>>> index = Rtree()
>>> index.add(id=id, bounds=(left, bottom, right, top))
>>> [n for n in index.intersection((left, bottom, right, top))]

This resembles a subset of the set protocol. add indexes a new object by id, intersection returns an iterator over ids where the node containing the id intersects with the specified bounding box. The intersection method is exact, with no false positives and no missed data. Ids can be ints or long ints; index queries return long ints.


First, download and install version 1.3 of the spatialindex library from:

The library is a GNU-style build, so it is just a matter of:

$ ./configure; make; make install

At this point you can get Rtree 0.4 via easy_install:

$ easy_install Rtree

or by running the local

$ python install

You can build and test in place like:

$ python test

Previous Versions

Users of Rtree versions <= 0.3 should use spatialindex 1.1.1. Download and install a copy of both spatialindex and tools libraries from:

Each library is a GNU-style build, so it should just be a matter of:

$ CPPFLAGS=-DNDEBUG ./configure; make; make install

for each. Debugging is on by default in 1.1.1, you’ll want to turn it off for use in production. The spatialindex library depends on the tools library, so make sure to build and install that first.


See tests/R-Tree.txt.


See the tests/ file for a comparison.


For current information about this project, see the wiki.

If you have questions, please consider joining our community list:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Rtree-0.4.1.tar.gz (29.4 kB view hashes)

Uploaded source

Built Distributions

Rtree-0.4.1.win32-py2.6.exe (322.5 kB view hashes)

Uploaded 2 6

Rtree-0.4.1-py2.6-win32.egg (254.0 kB view hashes)

Uploaded 2 6

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page