as_data_frame: Convert a 'Quadtree' to a data frame

as_data_frameR Documentation

Convert a Quadtree to a data frame

Description

Creates a data frame with information on each quadtree cell.

Usage

## S4 method for signature 'Quadtree'
as_data_frame(x, terminal_only = TRUE)

Arguments

x

a Quadtree

terminal_only

boolean; if TRUE (the default) only information on terminal cells is returned. If FALSE, information on all cells is returned.

Value

A data frame with one row for each quadtree cell. The columns are as follows:

  • id: the id of the cell

  • hasChildren: 1 if the cell has children, 0 otherwise

  • level: integer; the depth of this cell/node in the quadtree, where the root of the quadtree is considered to be level 0

  • xmin, xmax, ymin, ymax: the x and y limits of the cell

  • value: the value of the cell

  • smallestChildLength: the smallest cell length among all of this cell's descendants

  • parentID: the ID of the cell's parent. The root, which has no parent, has a value of -1 for this column

See Also

as_vector() returns all the cell values as a numeric vector.

Examples

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)

quadtree documentation built on Aug. 29, 2023, 5:11 p.m.