| 1 |
Rtree |
|---|
| 2 |
===== |
|---|
| 3 |
|
|---|
| 4 |
Whether for in-memory feature stores, Plone content, or whatever -- we need an |
|---|
| 5 |
index to speed up the search for objects that intersect with a spatial bounding |
|---|
| 6 |
box. |
|---|
| 7 |
|
|---|
| 8 |
See also CHANGES.txt_. |
|---|
| 9 |
|
|---|
| 10 |
.. _CHANGES.txt: http://trac.gispython.org/projects/PCL/browser/Rtree/trunk/CHANGES.txt |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
Index Protocol |
|---|
| 14 |
-------------- |
|---|
| 15 |
|
|---|
| 16 |
In a nutshell:: |
|---|
| 17 |
|
|---|
| 18 |
>>> from rtree import Rtree |
|---|
| 19 |
>>> index = Rtree() |
|---|
| 20 |
>>> index.add(id=id, bounds=(left, bottom, right, top)) |
|---|
| 21 |
>>> [n for n in index.intersection((left, bottom, right, top))] |
|---|
| 22 |
[id] |
|---|
| 23 |
|
|---|
| 24 |
This resembles a subset of the set protocol. *add* indexes a new object by id, |
|---|
| 25 |
*intersection* returns an iterator over ids where the node containing the id |
|---|
| 26 |
intersects with the specified bounding box. The *intersection* method is |
|---|
| 27 |
exact, with no false positives and no missed data. Ids can be ints or long |
|---|
| 28 |
ints; index queries return long ints. |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
Installation |
|---|
| 32 |
------------ |
|---|
| 33 |
|
|---|
| 34 |
First, download and install version 1.3 of the spatialindex library from: |
|---|
| 35 |
|
|---|
| 36 |
http://trac.gispython.org/projects/SpatialIndex/wiki/Releases |
|---|
| 37 |
|
|---|
| 38 |
The library is a GNU-style build, so it is just a matter of:: |
|---|
| 39 |
|
|---|
| 40 |
$ ./configure; make; make install |
|---|
| 41 |
|
|---|
| 42 |
At this point you can get Rtree 0.4 via easy_install:: |
|---|
| 43 |
|
|---|
| 44 |
$ easy_install Rtree |
|---|
| 45 |
|
|---|
| 46 |
or by running the local setup.py:: |
|---|
| 47 |
|
|---|
| 48 |
$ python setup.py install |
|---|
| 49 |
|
|---|
| 50 |
You can build and test in place like:: |
|---|
| 51 |
|
|---|
| 52 |
$ python setup.py test |
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
Previous Versions |
|---|
| 56 |
+++++++++++++++++ |
|---|
| 57 |
|
|---|
| 58 |
Users of Rtree versions <= 0.3 should use spatialindex 1.1.1. Download and |
|---|
| 59 |
install a copy of both spatialindex and tools libraries from: |
|---|
| 60 |
|
|---|
| 61 |
http://research.att.com/~marioh/tools/index.html |
|---|
| 62 |
|
|---|
| 63 |
http://research.att.com/~marioh/spatialindex/index.html |
|---|
| 64 |
|
|---|
| 65 |
Each library is a GNU-style build, so it should just be a matter of:: |
|---|
| 66 |
|
|---|
| 67 |
$ CPPFLAGS=-DNDEBUG ./configure; make; make install |
|---|
| 68 |
|
|---|
| 69 |
for each. Debugging is on by default in 1.1.1, you'll want to turn it off for |
|---|
| 70 |
use in production. The spatialindex library depends on the tools library, so |
|---|
| 71 |
make sure to build and install that first. |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
Usage |
|---|
| 75 |
----- |
|---|
| 76 |
|
|---|
| 77 |
See `tests/R-Tree.txt`_. |
|---|
| 78 |
|
|---|
| 79 |
.. _tests/R-Tree.txt: http://trac.gispython.org/projects/PCL/browser/Rtree/trunk/tests/R-Tree.txt |
|---|
| 80 |
|
|---|
| 81 |
Performance |
|---|
| 82 |
----------- |
|---|
| 83 |
|
|---|
| 84 |
See the tests/benchmarks.py file for a comparison. |
|---|
| 85 |
|
|---|
| 86 |
Support |
|---|
| 87 |
------- |
|---|
| 88 |
|
|---|
| 89 |
For current information about this project, see the wiki_. |
|---|
| 90 |
|
|---|
| 91 |
.. _wiki: http://trac.gispython.org/projects/PCL/wiki/Rtree |
|---|
| 92 |
|
|---|
| 93 |
If you have questions, please consider joining our community list: |
|---|
| 94 |
|
|---|
| 95 |
http://trac.gispython.org/projects/PCL/wiki/CommunityList |
|---|
| 96 |
|
|---|