Create a search tree from the supplied data for use in during future lookups.
createTree(data, treeType = "quad", dataType = "point",
columns = if (dataType=="point") 1:2 else 1:4, ...)
The class of the returned object depends on the tree type created,
though all will inherit from the SearchTree
S4 class and have the
following slots:
An external pointer to the C level data structure.
Total number of nodes comprising the tree.
Number of nodes which store at least one data point.
Maximum depth of the tree.
Maximum number of data points stored in a single node.
Number of items indexed in the tree.
Type of objects stored in the tree.
data.frame or matrix. Data to be indexed.
Character. Indicates type of index tree to be created. Currently only "quad" (quad trees) is supported.
Character. Indicates type of data being indexed. Currently "point", and "rect" are supported corresponding to points and rectangles, respectively. Defaults to "point".
Numeric. Indicates columns in data
the information to be
indexed can be found. Length depends on value of dataType
(2
for "point" and 4 for "rect"). Defaults to columns 1 and 2. See Details.
Any additional/type specific parameters to be passed to the tree creation function. These include:
Numeric. Maximum depth of the tree. Defaults to 7.
Numeric. Minimum (rectangular) area to be represented by a
single node. When set, this overrides maxDepth
Gabriel Becker
For a point based tree, the two columns specified in columns
represent the x and y values of the points.
For a rectangle based tree, four columns must be specified. These columns represent the x and y coordinates of point 1 and the x and y coordinates of point 2, in that order (where point 1 and point 2 specify the rectangle to be stored).
Finkel, R. A. and Bentley, J. L. "Quad Trees, a Data Structure for Retrieval on Composite Keys." Acta Informatica 4, 1-9, 1974.
SearchTree
linkS4Class{QuadTree}
x = rnorm(100)
y = rnorm(100)
dat = cbind(x,y)
tree = createTree(dat)
Run the code above in your browser using DataLab