Returns the number of nodes/cells in the quadtree.
# S4 method for Quadtree
n_cells(x, terminal_only = TRUE)
a Quadtree
boolean; if TRUE
(the default) only the terminal
nodes are counted. If FALSE
, all nodes are counted, thereby giving the
total number of nodes in the tree.
a numeric
library(quadtree)
habitat <- terra::rast(system.file("extdata", "habitat.tif", package="quadtree"))
qt <- quadtree(habitat, .1)
n_cells(qt)
#> [1] 5911
n_cells(qt, terminal_only = FALSE)
#> [1] 7881