powered by
Quadtree
Creates a data frame with information on each quadtree cell.
# S4 method for Quadtree as_data_frame(x, terminal_only = TRUE)
A data frame with one row for each quadtree cell. The columns are as follows:
id: the id of the cell
id
hasChildren: 1 if the cell has children, 0 otherwise
hasChildren
level: integer; the depth of this cell/node in the quadtree, where the root of the quadtree is considered to be level 0
level
xmin, xmax, ymin, ymax: the x and y limits of the cell
xmin
xmax
ymin
ymax
value: the value of the cell
value
smallestChildLength: the smallest cell length among all of this cell's descendants
smallestChildLength
parentID: the ID of the cell's parent. The root, which has no parent, has a value of -1 for this column
parentID
a Quadtree
boolean; if TRUE (the default) only information on terminal cells is returned. If FALSE, information on all cells is returned.
TRUE
FALSE
as_vector() returns all the cell values as a numeric vector.
as_vector()
library(quadtree) mat <- rbind(c(1, 1, 0, 1), c(1, 1, 1, 0), c(1, 0, 1, 1), c(0, 1, 1, 1)) qt <- quadtree(mat, .1) plot(qt) as_data_frame(qt)
Run the code above in your browser using DataLab