Learn R Programming

quadtree (version 0.1.14)

read_quadtree: Read/write a Quadtree

Description

Reads and writes a Quadtree.

Usage

# S4 method for character
read_quadtree(x)

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

Value

read_quadtree() - returns a Quadtree

write_quadtree() - no return value

Arguments

x

character; the filepath to read from or write to

y

a Quadtree

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

Run this code
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)

Run the code above in your browser using DataLab