Reads and writes a Quadtree.

# S4 method for character
read_quadtree(x)

# S4 method for character,Quadtree
write_quadtree(x, y)

Arguments

x

character; the filepath to read from or write to

y

a Quadtree

Value

read_quadtree() - returns a Quadtree

write_quadtree() - no return value

Details

To read/write a quadtree object, the C++ library cereal is used to serialize the quadtree and save it to a file. The file extension is unimportant - it can be anything (I've been using the extension '.qtree').

Examples

library(quadtree)
habitat <- terra::rast(system.file("extdata", "habitat.tif", package="quadtree"))

qt <- quadtree(habitat, .1)

path <- tempfile(fileext = "qtree")
write_quadtree(path, qt)
qt2 <- read_quadtree(path)