R/zzz.R

Defines functions .onLoad

# reference: https://rstudio.github.io/reticulate/articles/package.html

#' InVEST object
#'
#' Uses the reticulate framework to access the InVEST API.
#'
#' The InVEST Python library is exposed through the `invest` object.
#'
#' In this package, use the `$` operator wherever you see the `.` operator
#' used in Python.
#'
#' @export invest
invest <- NULL

#' @importFrom reticulate import
.onLoad <- function(libname, pkgname) {
  # tryCatch(
  #   reticulate::use_condaenv(condaenv = "r-reticulate", required = TRUE),
  #   error = Sys.sleep(0))

  invest <<- reticulate::import("natcap.invest", delay_load = TRUE)
}
jsta/rinvest documentation built on March 17, 2023, 6:15 a.m.