A thin reticulate-backed wrapper for reading the CTrees aboveground
biomass Zarr cube from Arraylake into a terra::SpatRaster. Note this
is not the best way to use these data we should work towards arraylake R
bindings, but this is a stopgap for now.
# install.packages("pak")
pak::pak("belian-earth/ctreesR")The Arraylake repository must be supplied: pass it as
session_auth(repo = "org/repo"), set options(ctreesR.repo = ...), or
set the CTREES_REPO environment variable (e.g. in ~/.Renviron). The
package does not ship a default repo.
Arraylake credentials are resolved in this order:
- The
tokenargument tosession_auth()(an Earthmover account API key, e.g.session_auth(token = "ema_...")). - The
EARTHMOVER_KEYenvironment variable. Use this in non-interactive deployments (containers, Shiny apps) where no browser is available. - The OAuth token cached at
~/.arraylake/token.jsonbyarraylake auth login. This is the default for interactive use.
library(ctreesR)
session <- session_auth()
ctrees <- open_ctrees(session)
bbx <- c( -73.2,-8.0, -72.1, -7.1)
bzr <- read_ctrees(ctrees, bbox = bbx, year_start = 2025, year_end = 2025)
terra::plot(bzr, range=c(0, 350), fill_range=TRUE)