Data layout Data in R-trees is organized in pages that can have a variable number of entries (up to some pre-defined maximum, and usually above a minimum fill). Each entry within a non-
leaf node stores two pieces of data: a way of identifying a
child node, and the
bounding box of all entries within this child node. Leaf nodes store the data required for each child, often a point or bounding box representing the child and an external identifier for the child. For point data, the leaf entries can be just the points themselves. For polygon data (that often requires the storage of large polygons) the common setup is to store only the MBR (minimum bounding rectangle) of the polygon along with a unique identifier in the tree.
Search The search process in an R-tree embodies a two-phase approach that aligns with the
Filter and Refine Principle (FRP). In this structure, the internal nodes serve as an initial filter by quickly excluding regions of space that do not intersect the query, while the leaf nodes provide a refined, precise evaluation by storing the actual spatial objects. Specifically, in
range searching, the input is a search rectangle (Query box). Searching is quite similar to searching in a
B+ tree. The search starts from the root node of the tree. Every internal node contains a set of rectangles and pointers to the corresponding child node and every leaf node contains the rectangles of spatial objects (the pointer to some spatial object can be there). For every rectangle in a node, it has to be decided if it overlaps the search rectangle or not. If yes, the corresponding child node has to be searched also. Searching is done like this in a recursive manner until all overlapping nodes have been traversed. When a leaf node is reached, the contained bounding boxes (rectangles) are tested against the search rectangle and their objects (if there are any) are put into the result set if they lie within the search rectangle. For priority search such as
nearest neighbor search, the query consists of a point or rectangle. The root node is inserted into the priority queue. Until the queue is empty or the desired number of results have been returned the search continues by processing the nearest entry in the queue. Tree nodes are expanded and their children reinserted. Leaf entries are returned when encountered in the queue. This approach can be used with various distance metrics, including
great-circle distance for geographic data. the
R*-tree splitting heuristic (which again tries to minimize overlap, but also prefers quadratic pages) or the linear split algorithm proposed by Ang and Tan (which however can produce very irregular rectangles, which are less performant for many real world range and window queries). In addition to having a more advanced splitting heuristic, the
R*-tree also tries to avoid splitting a node by reinserting some of the node members, which is similar to the way a
B-tree balances overflowing nodes. This was shown to also reduce overlap and thus increase tree performance. Finally, the
X-tree can be seen as a R*-tree variant that can also decide to not split a node, but construct a so-called super-node containing all the extra entries, when it doesn't find a good split (in particular for high-dimensional data).
Deletion Deleting an entry from a page may require updating the bounding rectangles of parent pages. However, when a page is underfull, it will not be balanced with its neighbors. Instead, the page will be dissolved and all its children (which may be subtrees, not only leaf objects) will be reinserted. If during this process the root node has a single element, the tree height can decrease.
Bulk-loading • Nearest-X: Objects are sorted by their first coordinate ("X") and then split into pages of the desired size. • Packed
Hilbert R-tree: variation of Nearest-X, but sorting using the Hilbert value of the center of a rectangle instead of using the X coordinate. There is no guarantee the pages will not overlap. • Sort-Tile-Recursive (STR): Another variation of Nearest-X, that estimates the total number of leaves required as l=\lceil \text{number of objects} / \text{capacity}\rceil, the required split factor in each dimension to achieve this as s=\lceil l^{1/d}\rceil, then repeatedly splits each dimensions successively into s equal sized partitions using 1-dimensional sorting. The resulting pages, if they occupy more than one page, are again bulk-loaded using the same algorithm. For point data, the leaf nodes will not overlap, and "tile" the data space into approximately equal sized pages. • Overlap Minimizing Top-down (OMT): Improvement over STR using a top-down approach which minimizes overlaps between slices and improves query performance. •
Priority R-tree == See also ==